MCPcopy Create free account
hub / github.com/dask/dask / f_oneway

Function f_oneway

dask/array/stats.py:376–407  ·  view source on GitHub ↗
(*args)

Source from the content-addressed store, hash-verified

374
375@derived_from(scipy.stats)
376def f_oneway(*args):
377 # args = [np.asarray(arg, dtype=float) for arg in args]
378 # ANOVA on N groups, each in its own array
379 num_groups = len(args)
380 alldata = da.concatenate(args)
381 bign = len(alldata)
382
383 # Determine the mean of the data, and subtract that from all inputs to a
384 # variance (via sum_of_sq / sq_of_sum) calculation. Variance is invariance
385 # to a shift in location, and centering all data around zero vastly
386 # improves numerical stability.
387 offset = alldata.mean()
388 alldata -= offset
389
390 sstot = _sum_of_squares(alldata) - (_square_of_sums(alldata) / float(bign))
391 ssbn = 0
392 for a in args:
393 ssbn += _square_of_sums(a - offset) / float(len(a))
394
395 # Naming: variables ending in bn/b are for "between treatments", wn/w are
396 # for "within treatments"
397 ssbn -= _square_of_sums(alldata) / float(bign)
398 sswn = sstot - ssbn
399 dfbn = num_groups - 1
400 dfwn = bign - num_groups
401 msb = ssbn / float(dfbn)
402 msw = sswn / float(dfwn)
403 f = msb / msw
404
405 prob = _fdtrc(dfbn, dfwn, f) # equivalent to stats.f.sf
406
407 return delayed(F_onewayResult, nout=2)(f, prob)
408
409
410@derived_from(scipy.stats)

Callers

nothing calls this directly

Calls 4

delayedFunction · 0.90
_sum_of_squaresFunction · 0.85
_square_of_sumsFunction · 0.85
meanMethod · 0.45

Tested by

no test coverage detected