Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: PDF to CDF in MATLAB
Replies: 5   Last Post: Jan 14, 2013 4:59 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Roger Stafford

Posts: 5,929
Registered: 12/7/04
Posted: Jan 14, 2013 4:59 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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 Klein-Nishina (KN) comes into play. I would like to create a distribution (a CDF), using the KN-function between 0-180 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 Klein-Nishina 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 Klein-Nishina 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 time-consuming 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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2016. All Rights Reserved.