Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 = mean + round(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],[]])

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 = mean round(mean + round(dist.get_random_element())
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],[]])