[Matplotlib] Ploting an exponential distribution frequency curve
marfig at gmail.com
Sun Apr 26 00:33:10 CEST 2015
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:
from random import expovariate
from collections import defaultdict
decimal.getcontext().prec = 4
Dec = decimal.Decimal
samples = 100000 # 100,000
res = defaultdict(int)
for _ in range(samples):
res[Dec(expovariate(lambd)).quantize(Dec('0.01'))] += 1
Trying to plot this data into a frequency curve is proving too
challenging and I just can't understand why.
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.
More information about the Python-list