Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
distribution function

Subject: distribution function

From: jeny hu

Date: 14 Mar, 2010 13:18:02

Message: 1 of 9

Hi,

i'm a beginner in matlab.I need to create distribution function of a meixner distribution:
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

and i don't know how.
could someone please help me?
thanks a lot

Subject: distribution function

From: Matt J

Date: 14 Mar, 2010 13:25:05

Message: 2 of 9

"jeny hu" <Yoggi@post.sk> wrote in message <hninma$k1$1@fred.mathworks.com>...

If you don't know how, what does the code you posted do?

Subject: distribution function

From: jeny hu

Date: 14 Mar, 2010 13:32:05

Message: 3 of 9

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hnio3h$6bt$1@fred.mathworks.com>...
> "jeny hu" <Yoggi@post.sk> wrote in message <hninma$k1$1@fred.mathworks.com>...
>
> If you don't know how, what does the code you posted do?

the code creates a probability density function and i need to create a distribution function

Subject: distribution function

From: Matt J

Date: 14 Mar, 2010 13:35:23

Message: 4 of 9

"jeny hu" <Yoggi@post.sk> wrote in message <hniogl$c6p$1@fred.mathworks.com>...

> the code creates a probability density function and i need to create a distribution function
===============

help cumsum

Subject: distribution function

From: jeny hu

Date: 14 Mar, 2010 13:48:02

Message: 5 of 9

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hniomr$eu4$1@fred.mathworks.com>...
> "jeny hu" <Yoggi@post.sk> wrote in message <hniogl$c6p$1@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

Subject: distribution function

From: Matt J

Date: 14 Mar, 2010 14:34:05

Message: 6 of 9

"jeny hu" <Yoggi@post.sk> wrote in message <hnipei$pn5$1@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.

Subject: distribution function

From: Walter Roberson

Date: 14 Mar, 2010 17:08:35

Message: 7 of 9

jeny hu wrote:
> "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message
> <hniomr$eu4$1@fred.mathworks.com>...
>> "jeny hu" <Yoggi@post.sk> wrote in message
>> <hniogl$c6p$1@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.

Subject: distribution function

From: Peter Perkins

Date: 15 Mar, 2010 13:45:08

Message: 8 of 9

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.

Subject: distribution function

From: jeny hu

Date: 15 Mar, 2010 15:50:27

Message: 9 of 9

Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <hnldl4$s0f$1@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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us