From: Helen Alter on 27 May 2010 23:17 I am interesting into splitting a theoretical exponential distribution (with parameter 0.02) into a given number of bins, and then count the values which lump into each bin. Moreover the last bins should be collated and up to infinity. I have tried the histc function I=20 %number of bins bins=0:10: 200; x=0:200; e=exppdf(x,0.02); histc(e, bins); is it correct? Thank you, Helen
From: Walter Roberson on 27 May 2010 23:34 Helen Alter wrote: > I am interesting into splitting a theoretical exponential distribution > (with parameter 0.02) into a given number of bins, and then count the > values which lump into each bin. Moreover the last bins should be > collated and up to infinity. > I have tried the histc function > I=20 %number of bins > bins=0:10: 200; > x=0:200; > e=exppdf(x,0.02); > histc(e, bins); > is it correct? In order to collect up to infinity in the last bin, you need to include infinity in your list of bins histc(e, [bins inf]) Does your distribution start from 0 or could it be negative? If you want to collect negative values as well, you will need to use an appropriate lower bound such as -inf . Possibly for your purposes you may wish to look at hist() instead of histc(). hist() automatically collects to infinity on both sides, and the parameter to histc can be given as the number of bins rather than the dividing points. If you do give explicit dividing points to hist() then they are treated as the centers of the bins rather than as the edges of the bins. Note: histc() does not draw a histogram. To draw the histogram, use bar(bins, histc(e,bins))
From: Tom Lane on 28 May 2010 09:42 >I am interesting into splitting a theoretical exponential distribution >(with parameter 0.02) into a given number of bins, and then count the >values which lump into each bin. Moreover the last bins should be collated >and up to infinity. > I have tried the histc function > I=20 %number of bins > bins=0:10: 200; > x=0:200; > e=exppdf(x,0.02); > histc(e, bins); Helen, let me first make sure you're doing what you intend. You appear to be evaluating the pdf at a number of x values, and making a histogram of the values of the pdf. That's a bit unusual. What's usually done is one of the following: 1. Generate data from the distribution, and do a histogram of those over some set of bins. Then you might combine bins with low counts if you intend to do a chi-square test or some such thing. 2. Define a set of bins, and compute the probability of each bin according to the theoretical distribution. In that case you'd want to evaluate the cdf at the bin edges, and take differences to get the probability assigned to each bin. You can set the last edge to Inf if you want. -- Tom
|
Pages: 1 Prev: auto_extraction of same value position Next: Matlab 2009b launching issues |