From: Matt J on
"jeny hu" <Yoggi(a)post.sk> wrote in message <hnipei$pn5$1(a)fred.mathworks.com>...

> > help cumsum
> I need the cdf for statistical testing(kstest,kuiper test....) and i know the result(accept H0) and I've already tried cumsum but this ends with rejecting H0
==============

That doesn't mean cumsum is wrong. It could mean there's aproblem somewhere else.
From: Walter Roberson on
jeny hu wrote:
> "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message
> <hniomr$eu4$1(a)fred.mathworks.com>...
>> "jeny hu" <Yoggi(a)post.sk> wrote in message
>> <hniogl$c6p$1(a)fred.mathworks.com>...
>>
>> > the code creates a probability density function and i need to create
>> a distribution function
>> ===============
>>
>> help cumsum
> I need the cdf for statistical testing(kstest,kuiper test....) and i
> know the result(accept H0) and I've already tried cumsum but this ends
> with rejecting H0

Your original code was:

function y=meixner(x,a,b,d,m)
x=x(:);
n=length(x);
for k=1:n
y(k)=(2*cos(b/2))^(2*d)*exp(b*(x(k)'-m)./a)*abs(gamma(d+i*(x(k)-m)./a)).^2/(2*a*pi*gamma(2*d));
y=y(:);
end


There is no H0 anywhere in there, so cumsum() applied to the output of
this function is not going to have any problem with H0.

What you do with the distribution function after you have it is a
different matter. Be sure you are asking us the right question.
From: Peter Perkins on
On 3/14/2010 9:18 AM, jeny hu wrote:

> i'm a beginner in matlab.I need to create distribution function of a
> meixner distribution:

This is a continuous distribution, correct? And presumably there is no closed form for the distribution? So you might consider using (for example) QUADGK to numerically integrate your PDF. CUMSUM probably isn't what you want, unless you are using it as a poor-man's numerical integration.

But you have a bit of a problem here: this line

> y(k)=(2*cos(b/2))^(2*d)*exp(b*(x(k)'-m)./a)*abs(gamma(d+i*(x(k)-m)./a)).^2/(2*a*pi*gamma(2*d));

calls the gamma function with a complex argument, and as the help says,

>> help gamma
GAMMA Gamma function.
Y = GAMMA(X) evaluates the gamma function for each element of X.
X must be real.

So you will have to find something other than GAMMA. The MATLAB File Exchange has what seems like a well-written version (also the very first google hit for "complex gamma matlab):

<http://www.mathworks.com/matlabcentral/fileexchange/978>

Other than that, there's no reason to loop over elements in computing the PDF, you can do it with one vectorized statement.
From: jeny hu on
Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <hnldl4$s0f$1(a)fred.mathworks.com>...
> On 3/14/2010 9:18 AM, jeny hu wrote:
>
> > i'm a beginner in matlab.I need to create distribution function of a
> > meixner distribution:
>
> This is a continuous distribution, correct? And presumably there is no closed form for the distribution? So you might consider using (for example) QUADGK to numerically integrate your PDF. CUMSUM probably isn't what you want, unless you are using it as a poor-man's numerical integration.
>
> But you have a bit of a problem here: this line
>
> > y(k)=(2*cos(b/2))^(2*d)*exp(b*(x(k)'-m)./a)*abs(gamma(d+i*(x(k)-m)./a)).^2/(2*a*pi*gamma(2*d));
>
> calls the gamma function with a complex argument, and as the help says,
>
> >> help gamma
> GAMMA Gamma function.
> Y = GAMMA(X) evaluates the gamma function for each element of X.
> X must be real.
>
> So you will have to find something other than GAMMA. The MATLAB File Exchange has what seems like a well-written version (also the very first google hit for "complex gamma matlab):
>
> <http://www.mathworks.com/matlabcentral/fileexchange/978>
>
> Other than that, there's no reason to loop over elements in computing the PDF, you can do it with one vectorized statement.


I use in that code gamma function for complex numbers,but still i have problem with the CDF