Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.random.f

numpy.random.f(dfnum,dfden,size=None)

Draw samples from an F distribution.

Samples are drawn from an F distribution with specified parameters,dfnum (degrees of freedom in numerator) anddfden (degrees offreedom in denominator), where both parameters should be greater thanzero.

The random variate of the F distribution (also known as theFisher distribution) is a continuous probability distributionthat arises in ANOVA tests, and is the ratio of two chi-squarevariates.

Parameters:

dfnum : int or array_like of ints

Degrees of freedom in numerator. Should be greater than zero.

dfden : int or array_like of ints

Degrees of freedom in denominator. Should be greater than zero.

size : int or tuple of ints, optional

Output shape. If the given shape is, e.g.,(m,n,k), thenm*n*k samples are drawn. If size isNone (default),a single value is returned ifdfnum anddfden are both scalars.Otherwise,np.broadcast(dfnum,dfden).size samples are drawn.

Returns:

out : ndarray or scalar

Drawn samples from the parameterized Fisher distribution.

See also

scipy.stats.f
probability density function, distribution or cumulative density function, etc.

Notes

The F statistic is used to compare in-group variances to between-groupvariances. Calculating the distribution depends on the sampling, andso it is a function of the respective degrees of freedom in theproblem. The variabledfnum is the number of samples minus one, thebetween-groups degrees of freedom, whiledfden is the within-groupsdegrees of freedom, the sum of the number of samples in each groupminus the number of groups.

References

[R224]Glantz, Stanton A. “Primer of Biostatistics.”, McGraw-Hill,Fifth Edition, 2002.
[R225]Wikipedia, “F-distribution”,http://en.wikipedia.org/wiki/F-distribution

Examples

An example from Glantz[1], pp 47-40:

Two groups, children of diabetics (25 people) and children from peoplewithout diabetes (25 controls). Fasting blood glucose was measured,case group had a mean value of 86.1, controls had a mean value of82.2. Standard deviations were 2.09 and 2.49 respectively. Are thesedata consistent with the null hypothesis that the parents diabeticstatus does not affect their children’s blood glucose levels?Calculating the F statistic from the data gives a value of 36.01.

Draw samples from the distribution:

>>>dfnum=1.# between group degrees of freedom>>>dfden=48.# within groups degrees of freedom>>>s=np.random.f(dfnum,dfden,1000)

The lower bound for the top 1% of the samples is :

>>>sort(s)[-10]7.61988120985

So there is about a 1% chance that the F statistic will exceed 7.62,the measured value is 36, so the null hypothesis is rejected at the 1%level.

Previous topic

numpy.random.exponential

Next topic

numpy.random.gamma

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp