For a given PMF p=f(\theta)
for \theta
between 0
and 2\pi
, i computed the CDF in Matlab as
theta=0:2*pi/n:2*pi
for i=1:n
cdf(i)=trapz(theta(1:i),p(1:i));
end
and the result is verified.
I tried to do the same with
cumsum
ascdf=cumsum(p)*(2*pi)/n
but the result is wrong. why?How can i compute the CDF if the given PMF is in 2D as
p=f(\theta,\phi)
? Can i do it without going into detail as explained here ?