scipy/stats/mstats_basic.py
def friedmanchisquare(*args):
    """Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA.
    This function calculates the Friedman Chi-square test for repeated measures
    and returns the result, along with the associated probability value.

    Each input is considered a given group. Ideally, the number of treatments
    among each group should be equal. If this is not the case, only the first
    n treatments are taken into account, where n is the number of treatments
    of the smallest group.
    If a group has some missing values, the corresponding treatments are masked
    in the other groups.
    The test statistic is corrected for ties.

    Masked values in one group are propagated to the other groups.

    Returns
    -------
    statistic : float
        the test statistic.
    pvalue : float
        the associated p-value.

    """
    data = argstoarray(*args).astype(float)
    k = len(data)
    if k < 3:
        raise ValueError("Less than 3 groups (%i): " % k +
                         "the Friedman test is NOT appropriate.")

    ranked = ma.masked_values(rankdata(data, axis=0), 0)
    if ranked._mask is not nomask:
        ranked = ma.mask_cols(ranked)
        ranked = ranked.compressed().reshape(k,-1).view(ndarray)
    else:
        ranked = ranked._data
    (k,n) = ranked.shape
    # Ties correction
    repeats = np.array([find_repeats(_) for _ in ranked.T], dtype=object)
    ties = repeats[repeats.nonzero()].reshape(-1,2)[:,-1].astype(int)
    tie_correction = 1 - (ties**3-ties).sum()/float(n*(k**3-k))

    ssbg = np.sum((ranked.sum(-1) - n*(k+1)/2.)**2)
    chisq = ssbg * 12./(n*k*(k+1)) * 1./tie_correction

    return FriedmanchisquareResult(chisq,
                                   distributions.chi2.sf(chisq, k-1))
Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA.
    This function calculates the Friedman Chi-square test for repeated measures
    and returns the result, along with the associated probability value.

    Each input is considered a given group. Ideally, the number of treatments
    among each group should be equal. If this is not the case, only the first
    n treatments are taken into account, where n is the number of treatments
    of the smallest group.
    If a group has some missing values, the corresponding treatments are masked
    in the other groups.
    The test statistic is corrected for ties.

    Masked values in one group are propagated to the other groups.

    Returns
    -------
    statistic : float
        the test statistic.
    pvalue : float
        the associated p-value.

    
Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA.
This function calculates the Friedman Chi-square test for repeated measures
and returns the result, along with the associated probability value.

Each input is considered a given group. Ideally, the number of treatments
among each group should be equal. If this is not the case, only the first
n treatments are taken into account, where n is the number of treatments
of the smallest group.
If a group has some missing values, the corresponding treatments are masked
in the other groups.
The test statistic is corrected for ties.

Masked values in one group are propagated to the other groups.

Returns

statistic : float
the test statistic.
pvalue : float
the associated p-value.
Friedman Chi - Square is a non - parametric one - way within - subjects ANOVA . This function calculates the Friedman Chi - square test for repeated measures and returns the result along with the associated probability value . Each input is considered a given group . Ideally the number of treatments among each group should be equal . If this is not the case only the first n treatments are taken into account where n is the number of treatments of the smallest group . If a group has some missing values the corresponding treatments are masked in the other groups . The test statistic is corrected for ties . Masked values in one group are propagated to the other groups . Returns statistic : float the test statistic . pvalue : float the associated p - value .
def friedmanchisquare(*args):
    data = argstoarray(*args).astype(float)
    k = len(data)
    if k < 3:
        raise ValueError("Less than 3 groups (%i): " % k +
                         "the Friedman test is NOT appropriate.")
    ranked = ma.masked_values(rankdata(data, axis=0), 0)
    if ranked._mask is not nomask:
        ranked = ma.mask_cols(ranked)
        ranked = ranked.compressed().reshape(k,-1).view(ndarray)
    else:
        ranked = ranked._data
    (k,n) = ranked.shape
    repeats = np.array([find_repeats(_) for _ in ranked.T], dtype=object)
    ties = repeats[repeats.nonzero()].reshape(-1,2)[:,-1].astype(int)
    tie_correction = 1 - (ties**3-ties).sum()/float(n*(k**3-k))
    ssbg = np.sum((ranked.sum(-1) - n*(k+1)/2.)**2)
    chisq = ssbg * 12./(n*k*(k+1)) * 1./tie_correction
    return FriedmanchisquareResult(chisq,
                                   distributions.chi2.sf(chisq, k-1))
def friedmanchisquare ( * args ) : data = argstoarray ( * args ) . astype ( float ) k = len ( data ) if k < 3 : raise ValueError ( "Less than 3 groups (%i): " % k + "the Friedman test is NOT appropriate." ) ranked = ma . masked_values ( rankdata ( data , axis = 0 ) , 0 ) if ranked . _mask is not nomask : ranked = ma . mask_cols ( ranked ) ranked = ranked . compressed ( ) . reshape ( k , - 1 ) . view ( ndarray ) else : ranked = ranked . _data ( k , n ) = ranked . shape repeats = np . array ( [ find_repeats ( _ ) for _ in ranked . T ] , dtype = object ) ties = repeats [ repeats . nonzero ( ) ] . reshape ( - 1 , 2 ) [ : , - 1 ] . astype ( int ) tie_correction = 1 - ( ties ** 3 - ties ) . sum ( ) / float ( n * ( k ** 3 - k ) ) ssbg = np . sum ( ( ranked . sum ( - 1 ) - n * ( k + 1 ) / 2. ) ** 2 ) chisq = ssbg * 12. / ( n * k * ( k + 1 ) ) * 1. / tie_correction return FriedmanchisquareResult ( chisq , distributions . chi2 . sf ( chisq , k - 1 ) )
Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA.
Friedman Chi - Square is a non - parametric one - way within - subjects ANOVA .
"""Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA.
    This function calculates the Friedman Chi-square test for repeated measures
    and returns the result, along with the associated probability value.

    Each input is considered a given group. Ideally, the number of treatments
    among each group should be equal. If this is not the case, only the first
    n treatments are taken into account, where n is the number of treatments
    of the smallest group.
    If a group has some missing values, the corresponding treatments are masked
    in the other groups.
    The test statistic is corrected for ties.

    Masked values in one group are propagated to the other groups.

    Returns
    -------
    statistic : float
        the test statistic.
    pvalue : float
        the associated p-value.

    """ # Ties correction