-- Draw pdf and cdf for Compton scattering -- number of bins N = 12 -- incident energy E = 0.1 10^6 eV omega = E / hbar joule = kilogram meter^2 / second^2 c = 299792458.0 meter / second eV = 1.602176634 10^(-19) joule h = 6.62607015 10^(-34) joule second hbar = h / float(2 pi) me = 9.1093837015 10^(-31) kilogram R = hbar omega / (me c^2) I = -cos(theta) / R^2 + log(1 + R (1 - cos(theta))) (1/R - 2/R^2 - 2/R^3) - 1 / (2 R (1 + R (1 - cos(theta)))^2) + 1 / (1 + R (1 - cos(theta))) (-2/R^2 - 1/R^3) pi = float(pi) -- use numerical value of pi F = (I - eval(I,theta,0)) / (eval(I,theta,pi) - eval(I,theta,0)) f = d(F,theta) "Probability density function" xrange = (0,pi) yrange = (0,1) draw(f,theta) "Cumulative distribution function" xrange = (0,pi) yrange = (0,1) draw(F,theta) "Bin probability" P = zero(N) for(k,1,N, P[k] = eval(F,theta,k pi/N) - eval(F,theta,(k-1) pi/N)) h(x) = test(x <= 0, 0, x > N, 0, P[ceiling(x)]) xrange = (0,N) yrange = (0,1) draw(h,x)
Run