Search code examples
matlabstatisticsdistributionrandomprobability-density

How to generate random numbers from cut-off log-normal distribution in Matlab?


The radii r is drawn from a cut-off log-normal distribution, which has a following probability density function:

pdf=((sqrt(2).*exp(-0.5*((log(r/rch)).^2)))./((sqrt(pi.*(sigma_nd.^2))...
    .*r).*(erf((log(rmax/rch))./sqrt(2.*(sigma_nd.^2)))-erf((log(rmin/rch))./sqrt(2.*(sigma_nd.^2))))));

rch, sigma_nd, rmax, and rmin are all constants.

I found the explanation from the net, but it seems difficult to find its integral and then take inverse in Matlab.


Solution

  • I checked, but my first instinct is that it looks like log(r/rch) is a truncated normal distribution with limits of log(rmin/rch) and log(rmax/rch). So you can generate the appropriate truncated normal random variable, say y, then r = rch * exp(y).

    You can generate truncated normal random variables by generating the untruncated values and replacing those that are outside the limits. Alternatively, you can do it using the CDF, as described by @PengOne, which you can find on the wikipedia page.

    I'm (still) not sure that your p.d.f. is completely correct, but what's most important here is the distribution.