"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.8e113
> 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 KolmogorovSmirnov 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
> > % Rayleighdistributed random numbers, paramater=2
> > R = raylrnd(2,100,1);
> > % Generate the Rayleigh CDF for parameter=2
> > % I'm going to input a 2column 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
