Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.04; 'from:addr:yahoo.co.uk': 0.04; 'curve': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'language.': 0.14; 'random': 0.14; 'collections': 0.16; 'defaultdict': 0.16; 'exponential': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'res': 0.16; 'subject:distribution': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'subject:] ': 0.20; 'import': 0.22; 'header:User- Agent:1': 0.23; 'why.': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'dec': 0.30; "i'm": 0.30; 'getting': 0.31; '100000': 0.31; 'decimal': 0.31; 'figure': 0.32; 'skip:d 20': 0.34; 'basic': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'url:org': 0.36; 'too': 0.37; 'challenging': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'generating': 0.39; 'success.': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'you.': 0.62; 'our': 0.64; 'charset:windows-1252': 0.65; 'here': 0.66; 'results': 0.69; '100,000': 0.84; 'received:as9105.com': 0.84; 'received:dsl.as9105.com': 0.84; 'received:dynamic.dsl.as9105.com': 0.84; 'numerous': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: [Matplotlib] Ploting an exponential distribution frequency curve Date: Sun, 26 Apr 2015 01:31:16 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 80-42-238-59.dynamic.dsl.as9105.com User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430008291 news.xs4all.nl 2902 [2001:888:2000:d::a6]:43138 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89407 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