how to generate random numbers wrt specific distribution function

2 views (last 30 days)
i want to generate random no. wrt given pdf, my pdf function is
f( = 2.*2.5.*(((x(1)-1.6580)./0.5).^1).*((1-(((x(1)-1.6580)./0.5)).^2)).^1.5;
plz help;
thanks

Answers (2)

the cyclist
the cyclist on 19 Jun 2011
I'm not sure how much this is going to help you, but in general I think you need the ability to invert the cumulative distribution function (cdf, not pdf). The last two posts in this thread talk about the method:
I know there is also a discussion of this topic in the book Numerical Recipes.

Walter Roberson
Walter Roberson on 19 Jun 2011
That is not a valid pdf.
The real portion of it runs from 237/200 to 437/200, consisting of two symmetric portions, the first of which is negative and the second of which is positive. The integral of the real portion is thus 0.
If one restricts oneself to the positive lobe, 337/200 to 437/200, the integral comes out as 1/2 -- but the cdf needs to come out as 1 for the pdf to be valid.
  4 Comments
Walter Roberson
Walter Roberson on 19 Jun 2011
I had transposed some digits in my calculation, so the boundaries I indicated above are not exactly correct: they should be 579/500 to 829/500 is negative and 829/500 to 1079/500 is positive. The positive lobe corresponds exactly to the range you are restricting to. And the integral of that lobe is 1/2 rather than 1, so your pdf is not valid. Your pdf would have to be multiplied by 2 in order to be valid over that range.
Walter Roberson
Walter Roberson on 19 Jun 2011
After multiplying your f by 2, the inverse cdf that I come up with is
829/500+(1/2)*sqrt(1-((f-1)^2)^(1/5))
Note: the inner expression should not be simplified to have (f-1)^(2/5) instead of ((f-1)^2)^(1/5) or else you when (f-1) is less than 0, the sign will not become positive before the root is taken, resulting in a complex value instead of a real value.
Also note: I do not currently understand why the above takes the range f = 0 to 2 when I compute a peak height for f of (3/400)*sqrt(46875) = 1.623797632

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!