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:
Hypothesis testing

Subject: Hypothesis testing

From: Eli

Date: 9 Feb, 2010 07:13:04

Message: 1 of 5

Matlab users,
I have 2 questions:
1)
I have a vector of values 'Noise' that should have a Rayleigh distribution.
I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. the vector is 50176 elements in length.
What is the best way to do this?
2)
I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. This vector is 10201 elements in length.
What is the best way to do this?

Thanks,
-Eli

Subject: Hypothesis testing

From: Eli

Date: 9 Feb, 2010 07:43:03

Message: 2 of 5

Question 2) should read:
I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Gaussian distribution. This vector is 10201 elements in length.
What is the best way to do this?

"Eli " <elechtma@ryerson.ca> wrote in message <hkr1u0$fq5$1@fred.mathworks.com>...
> Matlab users,
> I have 2 questions:
> 1)
> I have a vector of values 'Noise' that should have a Rayleigh distribution.
> I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. the vector is 50176 elements in length.
> What is the best way to do this?
> 2)
> I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. This vector is 10201 elements in length.
> What is the best way to do this?
>
> Thanks,
> -Eli

Subject: Hypothesis testing

From: Wayne King

Date: 9 Feb, 2010 12:39:04

Message: 3 of 5

"Eli " <elechtma@ryerson.ca> wrote in message <hkr3m7$59a$1@fred.mathworks.com>...
> Question 2) should read:
> I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Gaussian distribution. This vector is 10201 elements in length.
> What is the best way to do this?
>
> "Eli " <elechtma@ryerson.ca> wrote in message <hkr1u0$fq5$1@fred.mathworks.com>...
> > Matlab users,
> > I have 2 questions:
> > 1)
> > I have a vector of values 'Noise' that should have a Rayleigh distribution.
> > I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. the vector is 50176 elements in length.
> > What is the best way to do this?
> > 2)
> > I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. This vector is 10201 elements in length.
> > What is the best way to do this?
> >
> > Thanks,
> > -Eli

Hi Eli, do you have the Statistics Toolbox? If so you can use the function kstest() and do a Kolmogorov-Smirnov goodness of fit test between empirical cumulative distribution function of your data against the cumulative distribution function of your desired distribution. For a Rayleigh distribution here is an example. I'm going to cheat and actually generate random numbers following that distribution (so we won't be able to reject the null hypothesis of course):

% Using Statistics Toolbox functions
% Rayleigh-distributed random numbers, paramater=2
R = raylrnd(2,100,1);
% Generate the Rayleigh CDF for parameter=2
% I'm going to input a 2-column matrix into kstest
x = (0:.01:100)';
P = raylcdf(x,2);
% Testing at the 0.05 level to see if the two are equal
[h,p,ksstat,cv] = kstest(R,[x P],0.05);
% returns h=0 we do not reject the null hypothesis that they are equal

You can do the same for any distribution, but obviously the CDF that you provide kstest() has to reflect that fact. I think you have enough samples so that the kstest will provide a good result.

Hope that helps,
Wayne

Subject: Hypothesis testing

From: Eli

Date: 9 Feb, 2010 18:15:06

Message: 4 of 5

Wayne,
Why are you entering P = raylcdf(x,2);
What about P = raylpdf(x,2);?
I am getting an h=1, meaning that my distribution does not seem to fit well.
h=1
p=5.8e-113
ksstat=.0508
cv=0.0061
Thanks again,
-Eli

"Wayne King" <wmkingty@gmail.com> wrote in message <hkrl18$ctc$1@fred.mathworks.com>...
> "Eli " <elechtma@ryerson.ca> wrote in message <hkr3m7$59a$1@fred.mathworks.com>...
> > Question 2) should read:
> > I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Gaussian distribution. This vector is 10201 elements in length.
> > What is the best way to do this?
> >
> > "Eli " <elechtma@ryerson.ca> wrote in message <hkr1u0$fq5$1@fred.mathworks.com>...
> > > Matlab users,
> > > I have 2 questions:
> > > 1)
> > > I have a vector of values 'Noise' that should have a Rayleigh distribution.
> > > I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. the vector is 50176 elements in length.
> > > What is the best way to do this?
> > > 2)
> > > I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. This vector is 10201 elements in length.
> > > What is the best way to do this?
> > >
> > > Thanks,
> > > -Eli
>
> Hi Eli, do you have the Statistics Toolbox? If so you can use the function kstest() and do a Kolmogorov-Smirnov goodness of fit test between empirical cumulative distribution function of your data against the cumulative distribution function of your desired distribution. For a Rayleigh distribution here is an example. I'm going to cheat and actually generate random numbers following that distribution (so we won't be able to reject the null hypothesis of course):
>
> % Using Statistics Toolbox functions
> % Rayleigh-distributed random numbers, paramater=2
> R = raylrnd(2,100,1);
> % Generate the Rayleigh CDF for parameter=2
> % I'm going to input a 2-column matrix into kstest
> x = (0:.01:100)';
> P = raylcdf(x,2);
> % Testing at the 0.05 level to see if the two are equal
> [h,p,ksstat,cv] = kstest(R,[x P],0.05);
> % returns h=0 we do not reject the null hypothesis that they are equal
>
> You can do the same for any distribution, but obviously the CDF that you provide kstest() has to reflect that fact. I think you have enough samples so that the kstest will provide a good result.
>
> Hope that helps,
> Wayne

Subject: Hypothesis testing

From: Wayne King

Date: 9 Feb, 2010 19:19:19

Message: 5 of 5

"Eli " <elechtma@ryerson.ca> wrote in message <hks8na$b73$1@fred.mathworks.com>...
> Wayne,
> Why are you entering P = raylcdf(x,2);
> What about P = raylpdf(x,2);?
> I am getting an h=1, meaning that my distribution does not seem to fit well.
> h=1
> p=5.8e-113
> ksstat=.0508
> cv=0.0061
> Thanks again,
> -Eli
>
> "Wayne King" <wmkingty@gmail.com> wrote in message <hkrl18$ctc$1@fred.mathworks.com>...
> > "Eli " <elechtma@ryerson.ca> wrote in message <hkr3m7$59a$1@fred.mathworks.com>...
> > > Question 2) should read:
> > > I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Gaussian distribution. This vector is 10201 elements in length.
> > > What is the best way to do this?
> > >
> > > "Eli " <elechtma@ryerson.ca> wrote in message <hkr1u0$fq5$1@fred.mathworks.com>...
> > > > Matlab users,
> > > > I have 2 questions:
> > > > 1)
> > > > I have a vector of values 'Noise' that should have a Rayleigh distribution.
> > > > I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. the vector is 50176 elements in length.
> > > > What is the best way to do this?
> > > > 2)
> > > > I have another vector 'Gnoise' that should have a gaussian distribution, but not centred at zero. I would like to preform a test to determine the how probable it is that this vector was in fact sampled from a Rayleigh distribution. This vector is 10201 elements in length.
> > > > What is the best way to do this?
> > > >
> > > > Thanks,
> > > > -Eli
> >
> > Hi Eli, do you have the Statistics Toolbox? If so you can use the function kstest() and do a Kolmogorov-Smirnov goodness of fit test between empirical cumulative distribution function of your data against the cumulative distribution function of your desired distribution. For a Rayleigh distribution here is an example. I'm going to cheat and actually generate random numbers following that distribution (so we won't be able to reject the null hypothesis of course):
> >
> > % Using Statistics Toolbox functions
> > % Rayleigh-distributed random numbers, paramater=2
> > R = raylrnd(2,100,1);
> > % Generate the Rayleigh CDF for parameter=2
> > % I'm going to input a 2-column matrix into kstest
> > x = (0:.01:100)';
> > P = raylcdf(x,2);
> > % Testing at the 0.05 level to see if the two are equal
> > [h,p,ksstat,cv] = kstest(R,[x P],0.05);
> > % returns h=0 we do not reject the null hypothesis that they are equal
> >
> > You can do the same for any distribution, but obviously the CDF that you provide kstest() has to reflect that fact. I think you have enough samples so that the kstest will provide a good result.
> >
> > Hope that helps,
> > Wayne

Hi Eli, I'm using raylcdf because kstest expects the cumulative distribution function, not the probability density function as an input. See
>>doc kstest

You can also construct and use a ProbDistUnivParam object like

b = 2; % or whatever you want
Pdist = ProbDistUnivParam('rayleigh', b);

It works with either a two column matrix of x and CDF values or a ProbDist object.

Again, I just picked the parameter 2 to show you. A Rayleigh pdf is characterized by that one parameter (b in MATLAB), so obviously if you have a hypothesis about that parameter you should incorporate that and not just follow my example.

Hope that helps,
Wayne

Tags for 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