Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: PDF to CDF in MATLAB Date: Sun, 13 Jan 2013 19:40:09 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 19 Message-ID: <kcv2ip$mv1$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-02-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1358106009 23521 172.30.248.47 (13 Jan 2013 19:40:09 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sun, 13 Jan 2013 19:40:09 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 3210880 Xref: news.mathworks.com comp.soft-sys.matlab:786491 Hi! Im trying to extract a scattering angle for a photon using the Klein-Nishina scattering angle distribution (KN in the code) and for this I need the CDF (of KN) to be able to use the Monte Carlo method when that is achieved. All i've managed so far is to plot the PDF between 0 degrees and Pi to see that it looks alright, and that it has that "peanut shape". Ive tried to use the built in CDF function but it seems very slow. E_gamma=0.140; alpha=0.511; P=zeros(3142,1); KN_matrix=zeros(3142, 1); for k=1:3142 j=(k-1)/1000; PE=1/(1+((E_gamma/alpha)*(1-cos(j)))); KN=(PE^2*(PE+(1/PE)-1+(cos(j))^2))/2; KN_matrix(k,1)=(KN); plot(j,KN_matrix(k,1)) hold on end Thanks! axis equal