Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: PDF to CDF in MATLAB
Posted:
Jan 14, 2013 4:59 AM


"Hemming" wrote in message <kd0dj0$bsu$1@newscl01ah.mathworks.com>... > Thanks for all the replies, i realize my formulation was very vague. Here's another go: > > My problem is that different scattering angles of Compton scattering have different propabilities. High energy photons is, for instance, more likely to scatter 2 degrees than 90. This is were KleinNishina (KN) comes into play. I would like to create a distribution (a CDF), using the KNfunction between 0180 degrees (which is my PDF). > So what i should do is integrate KN with respect to the scattering angle (j) (create the inverse of this function as you put it Roger) and this has proved difficult by hand. > If this could be achieved i would use this CDF to randomly select points in the distribution representing different angles. > > I hope this clears it up a bit, otherwise i'll give it another go. Thanks again! > > Hemming           My understanding is that the KleinNishina formula gives a differential cross section for photons which amounts to a relative probability density with respect to solid angle. That is, roughly speaking it is the relative probability of a scattering within some tiny solid angle divided by the amount of that solid angle. This means that to get a cumulative probability distribution it is necessary to take the integral of this KleinNishina expression with respect to cos(theta) where theta is the angle of scattering because of the nature of solid angle measure. This is different from integrating with respect to just theta. It also means that it is fairly easy to obtain this integral since if we substitute x = cos(theta), it would then be the integral of a rational function of x with respect to x. This is just a problem in partial fractions which is solved using elementary calculus. Some of the resulting terms will give rise to other rational functions of x, but one of them yields a logarithm expression. With the proper scaling and substituting cos(theta) again in place of x you would then have a valid cumulative distribution function as a function of theta. As I say, this is fairly easy to do. It does not require any numerical computation.
However, to do a Monte Carlo simulation of this process using a random number generator which has a uniform distribution like matlab's 'rand' function, it is necessary to find the inverse of the above CDF. By this I mean that the random number generator generates a value and you must then find a value of theta that would give the CDF function that random value. This is the reverse of directly evaluating the CDF given a value of theta. It is the combination of the rational terms and logarithm terms in the CDF expression that makes it unlikely that an explicit formula can be found to do this. Matlab does have functions like 'fzero' which can solve implicit equations but these are somewhat timeconsuming and depend on making good initial estimates.
There are also what are known as 'rejection' methods in which a certain fraction of random numbers generated must be rejected in such a way as to give the appropriate distribution. I would say that as things stand at the moment it looks as though such a rejection method would be your best bet for doing a Monte Carlo procedure of this scattering, in spite of the need to generate considerably more random numbers.
Roger Stafford



