# integers following Normal distribution

Hello,

how can I produce positive integers, say in (1,n), which follow the normal distribution with parameters (m,sigma).

Thanks.

integers following Normal distribution

**
asked 2012-12-21 07:55:36 +0100 **

Anonymous

Hello,

how can I produce positive integers, say in (1,n), which follow the normal distribution with parameters (m,sigma).

Thanks.

add a comment

0

I think it is pretty self explanatory:

```
# Sample size (not counting negatives!)
sample_size = 10000
# Parameters of the distribution
mean = 10
sigma = 10
dist = RealDistribution('gaussian', sigma)
# Getting the elements (notice the 'mean' in 'event'!)
sample = []
while len(sample) < sample_size :
event = round(mean + dist.get_random_element())
if event >= 0 :
sample.append(event)
# Getting the frequencies and plotting
sample_range = range(min(sample),1+max(sample))
frequencies = [sample.count(i) for i in sample_range]
list_plot(zip(sample_range,frequencies),gridlines=[[mean,mean-sigma,mean+sigma],[]])
```

0

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2012-12-21 07:55:36 +0100 **

Seen: **1,129 times**

Last updated: **Dec 22 '12**

Distribution of a list of numbers

How do I generate a random number according to the binomial distribution?

Generating random normal vectors and matrices

Best way to handle probability distributions

Comparaisons between different linux distributions

Seed - probability distribution functions

log-normal and gaussian distribution - array generation

how to get a log distribution on the x-axis of a semilogx plot?

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.