Skip to content

Commit

Permalink
Expanded documentation on ddof
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudiaComito committed Apr 1, 2020
1 parent 302d802 commit 1efa36d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions heat/core/dndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3399,6 +3399,15 @@ def var(self, axis=None, ddof=0, **kwargs):
represents the number of elements. Default: ddof=0. If ddof=1, the Bessel correction will be applied.
Setting ddof > 1 raises a NotImplementedError.
Notes on ddof (from numpy)
--------------------------
The variance is the average of the squared deviations from the mean, i.e., var = mean(abs(x - x.mean())**2).
The mean is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor
N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the
variance of a hypothetical infinite population. ddof=0 provides a maximum likelihood estimate of the variance
for normally distributed variables.
Examples
--------
>>> a = ht.random.randn(1,3)
Expand Down
10 changes: 9 additions & 1 deletion heat/core/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ def var(x, axis=None, ddof=0, **kwargs):
The dtype of x must be a float
axis : None, Int, iterable, defaults to None
Axis which the variance is taken in. Default None calculates variance of all data items.
ddof : int, optional
ddof : int, optional (see Notes)
Delta Degrees of Freedom: the denominator implicitely used in the calculation is N - ddof, where N
represents the number of elements. Default: ddof=0. If ddof=1, the Bessel correction will be applied.
Setting ddof > 1 raises a NotImplementedError.
Expand All @@ -1178,6 +1178,14 @@ def var(x, axis=None, ddof=0, **kwargs):
if axis > split, then variances.split = x.split
if axis < split, then variances.split = x.split - 1
Notes on ddof (from numpy)
--------------------------
The variance is the average of the squared deviations from the mean, i.e., var = mean(abs(x - x.mean())**2).
The mean is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor
N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the
variance of a hypothetical infinite population. ddof=0 provides a maximum likelihood estimate of the variance
for normally distributed variables.
Examples
--------
>>> a = ht.random.randn(1,3)
Expand Down

0 comments on commit 1efa36d

Please sign in to comment.