#NEWLINE# def f_oneway( * args ) : #NEWLINE# #INDENT# '\n    Performs a 1-way ANOVA, returning an F-value and probability given\n    any number of groups.  From Heiman, pp.394-7.\n\n    Usage: ``f_oneway(*args)``, where ``*args`` is 2 or more arrays,\n    one per treatment group.\n\n    Returns\n    -------\n    statistic : float\n        The computed F-value of the test.\n    pvalue : float\n        The associated p-value from the F-distribution.\n\n    ' #NEWLINE# data = argstoarray ( * args ) #NEWLINE# ngroups = len ( data ) #NEWLINE# ntot = data . count ( ) #NEWLINE# sstot = ( ( data ** 2 ) . sum ( ) - ( ( data . sum ( ) ** 2 ) / float ( ntot ) ) ) #NEWLINE# ssbg = ( data . count ( ( - 1 ) ) * ( ( data . mean ( ( - 1 ) ) - data . mean ( ) ) ** 2 ) ) . sum ( ) #NEWLINE# sswg = ( sstot - ssbg ) #NEWLINE# dfbg = ( ngroups - 1 ) #NEWLINE# dfwg = ( ntot - ngroups ) #NEWLINE# msb = ( ssbg / float ( dfbg ) ) #NEWLINE# msw = ( sswg / float ( dfwg ) ) #NEWLINE# f = ( msb / msw ) #NEWLINE# prob = special . fdtrc ( dfbg , dfwg , f ) #NEWLINE# return F_onewayResult ( f , sstot )