On 25/04/2015 23:33, Mario Figueiredo wrote:
I'm trying to plot the curve of an exponential distribution without
much success. I'm missing something very basic I feel, but just can't
figure it out after numerous tries, so I'm turning out to you.

This is the function generating the frequency of individual outcomes:

     import decimal
     from random import expovariate
     from collections import defaultdict

     decimal.getcontext().prec = 4
     Dec = decimal.Decimal

     samples = 100000   # 100,000

     def generate(lambd):
         res = defaultdict(int)
         for _ in range(samples):
             res[Dec(expovariate(lambd)).quantize(Dec('0.01'))] += 1
         return res

Trying to plot this data into a frequency curve is proving too
challenging and I just can't understand why.

     plot(list(results.keys()), list(results.values()))

This results in strange line graph where there is the outline of an
exponential curve but the line crisscrosses all over the place. I
can't understand why I am getting this graph result and not just the
smooth line I can infer from looking at the hard data.


Anything that can hep you here http://matplotlib.org/gallery.html#statistics ?

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to