Chi-square goodness-of-fit test of Rayleighchannel

Discussion in 'MATLAB' started by Nicol?s Vignale, Sep 14, 2007.

  1. I´m doing a Fading Channel (rayleighchan) and i would like
    test the equivalence of the probability density function of
    the sampled data to Rayleigh density function with a "chi-
    square goodness-of-fit test" (chi2gof).

    The hypothesis of Rayleigh is allways rejected ! Although
    the Histogram looks like Rayleigh Way?

    Thanks for your help !
    Nicol?s Vignale, Sep 14, 2007
    1. Advertisements

  2. Nicol?s Vignale

    Nicolas Guest

    Here goes my code:

    sigma = 1/sqrt(2);
    c1 = rayleighchan; % Create object.
    c1.InputSamplePeriod = 1/2400;
    c1.PathDelays = [0 2e-3]; % number of delays.
    c1.MaxDopplerShift = 10; % Hz
    c1.DopplerSpectrum = ...
    c1.ResetBeforeFiltering = 1;
    t = [0:c1.InputSamplePeriod:(10000*c1.InputSamplePeriod)];
    y = [ones(1, length(t))*i]'; % input signal
    post_channel = filter(c1, y); % output signal
    [n, xout] = hist(abs(post_channel), 20);
    bar(xout, n);

    % Chi Square Test
    [h,p, stats] = ...
    chi2gof(abs(post_channel),'cdf',{@raylcdf}, 'nbins', 30)

    if (h == 1)
    Nicolas, Sep 14, 2007
    1. Advertisements

  3. Nicol?s Vignale

    Tom Lane Guest

    I´m doing a Fading Channel (rayleighchan) and i would like
    Nicolas, I'm not familiar with rayleighchan. But if I run your code from
    the other post and fit a Rayleigh distribution, I get this:
    ans =

    You compared against a standard Rayleigh. To compare against the
    distribution with this parameter value, you can use:
    h =
    p =
    stats =
    chi2stat: 36.9709
    df: 27
    edges: [1x30 double]
    O: [1x29 double]
    E: [1x29 double]

    The 'nparams' parameter tells the chi2gof function to take into account that
    the parameter has been estimated from the data.

    -- Tom
    Tom Lane, Sep 14, 2007
  4. Nicholas, your code is comparing to the "standard" Rayleigh, i.e., with
    parameter 1. You almost certainly want to compare against the best-fit
    Rayleigh. I think this is what you want:

    x = abs(post_channel);
    p = raylfit(x)
    [h,p, stats] = chi2gof(x,'cdf',@(x) raylcdf(x,p), 'nbins', 30, 'nparams',2)

    I get a p-value of .075, which still might seem small, given, for example, the
    CDF plot you can make by reading abs(post_channel) into the DFITTOOL GUI,
    fitting a Rayleigh dist'n, and plotting the fitted CDF against the empirical CDF
    (an exercise that I recommend).

    The small p-value is, I believe, due to a standard phenomenon when you have a
    large amount of data -- small departures from the theoretical dist'n, departures
    that have no _practical_ significance, make the data seem "unlikely" by a
    probabilistic measure used in the chi-squared test, simply because the large
    amount of data give the test such a high power, and thus the departures are
    given _statistical_ significance.

    Run the same test with several subsample of size, say, 1000, generated using
    RANDSAMPLE. You'll find the p-values are typically larger. Fewer data, lower

    Hope this helps.

    - Peter Perkins
    The MathWorks, Inc.
    Peter Perkins, Sep 14, 2007
  5. Nicol?s Vignale

    Nicolas Guest

    Tom, Peter;

    Thanks a lot for the helpful comments!!

    Peter: Why have you used nparams = 2 instead of 1?
    chi2gof(x,'cdf',@(x) raylcdf(x,p), 'nbins', 30, 'nparams',2)
    Nicolas, Sep 14, 2007

  6. 'cause I'm a dope. Cut and paste error. Should be 1, of course.
    Peter Perkins, Sep 14, 2007
  7. Nicol?s Vignale

    Zhihong Guest

    Zhihong, Nov 8, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.