Hover over the menu bar to pick a physics animation.

Random Creation of Probability Function Profiles

This animation demonstrates how one can choose random numbers that will result in a needed probability profile like a gaussian or an exponential which are demonstrated here. For quantum mechanics simulations or animations, such randomly selected values are needed because there is no a priori way of deciding where on the particular profile bins the next particle will be added. A prime example is electron or photon diffraction by a screen with multiple slits.

As one can see from the graph, the red fiducials separation is proportional to the abscissa of the required profile.

So to define a system where random number selection leads to an expected profile function we first define an array, `fA[0->N-1]`, of `N` elements which represents the expected profile function. Then we define another array of integer values,`nA[0->N-1]`, where the separation of the of the array elements is proportional to values of `fA[i]` :.

`nA[i]-nA[i-1]=r_(max)/NfA[i]`

where `r_(max)` is the large maximum random value that we will use in selecting random numbers.

To actually show the resulting randomly selected profile we will also define a bin array, `bA[0->N-1]`. When a chosen random number falls between `nA[i]` and `nA[i-1]` the `bA[i]` will be incremented by 1. The plots below show the function to be randomly simulated as well as red fiducials along the `x` axis. An array nA[i] contains the integer values represented by these fiducials. When we use the array we select a random number (shown as a blue dot) between 0 and the value of `r_(max) which is the last element of `nA[]`. This random number is more likely to fall within one of the wider fiducial spacings and when it does, a bin associated with that fiducial is incremented. This results in a statistically valid representation of the required probability profile and after many iterations the resulting discrete histogram agrees well with the algebraic (smooth line) profile.

To see how the statistical profile is built up the learner should select the Single Step check box. Then you comfortably can see the blue dot that represents the random number selected and see how the bin associated with that random number if incremented.

As in all of the physicsanimations.org/index applications, you can see the javascript source code by pressing F12 and selecting Sources and then pressing F5 to restart the program.