Statistics related stuff in igraph
Class |
|
Result of fitting a power-law to a vector of samples |
Class |
|
Generic histogram class for real numbers |
Class |
|
Running mean calculator. |
Function | mean |
Returns the mean of an iterable. |
Function | median |
Returns the median of an unsorted or sorted numeric vector. |
Function | percentile |
Returns the pth percentile of an unsorted or sorted numeric vector. |
Function | power |
Fitting a power-law distribution to empirical data |
Function | quantile |
Returns the qth quantile of an unsorted or sorted numeric vector. |
Function | sd |
Returns the standard deviation of an iterable. |
Function | var |
Returns the variance of an iterable. |
Returns the mean of an iterable.
Example:
>>> mean([1, 4, 7, 11]) 5.75
Parameters | |
xs | an iterable yielding numbers. |
Returns | |
the mean of the numbers provided by the iterable. | |
See Also | |
RunningMean() if you also need the variance or the standard deviation |
Returns the median of an unsorted or sorted numeric vector.
Parameters | |
xs | the vector itself. |
sort | whether to sort the vector. If you know that the vector is sorted already, pass False here. |
Returns | |
the median, which will always be a float, even if the vector contained integers originally. |
Returns the pth percentile of an unsorted or sorted numeric vector.
This is equivalent to calling quantile(xs, p/100.0); see quantile
for more details on the calculation.
Example:
>>> round(percentile([15, 20, 40, 35, 50], 40), 2) 26.0 >>> for perc in percentile([15, 20, 40, 35, 50], (0, 25, 50, 75, 100)): ... print("%.2f" % perc) ... 15.00 17.50 35.00 45.00 50.00
Parameters | |
xs | the vector itself. |
p | the percentile we are looking for. It may also be a list if you want to calculate multiple quantiles with a single call. The default value calculates the 25th, 50th and 75th percentile. |
sort | whether to sort the vector. If you know that the vector is sorted already, pass False here. |
Returns | |
the pth percentile, which will always be a float, even if the vector contained integers originally. If p is a list, the result will also be a list containing the percentiles for each item in the list. |
Fitting a power-law distribution to empirical data
Parameters | |
data | the data to fit, a list containing integer values |
xmin | the lower bound for fitting the power-law. If None, the optimal xmin value will be estimated as well. Zero means that the smallest possible xmin value will be used. |
method | the fitting method to use. The following methods are implemented so far:
|
return | Undocumented |
Returns | |
a FittedPowerLaw object. The fitted xmin value and the power-law exponent can be queried from the xmin and alpha properties of the returned object. | |
Unknown Field: newfield | |
ref | Reference |
Unknown Field: ref | |
MEJ Newman: Power laws, Pareto distributions and Zipf's law. Contemporary Physics 46, 323-351 (2005) | |
A Clauset, CR Shalizi, MEJ Newman: Power-law distributions in empirical data. E-print (2007). arXiv:0706.1062 |
Returns the qth quantile of an unsorted or sorted numeric vector.
There are a number of different ways to calculate the sample quantile. The method implemented by igraph is the one recommended by NIST. First we calculate a rank n as q(N+1), where N is the number of items in xs, then we split n into its integer component k and decimal component d. If k <= 1, we return the first element; if k >= N, we return the last element, otherwise we return the linear interpolation between xs[k-1] and xs[k] using a factor d.
Example:
>>> round(quantile([15, 20, 40, 35, 50], 0.4), 2) 26.0
Parameters | |
xs | the vector itself. |
q | the quantile we are looking for. It may also be a list if you want to calculate multiple quantiles with a single call. The default value calculates the 25th, 50th and 75th percentile. |
sort | whether to sort the vector. If you know that the vector is sorted already, pass False here. |
Returns | |
the qth quantile, which will always be a float, even if the vector contained integers originally. If q is a list, the result will also be a list containing the quantiles for each item in the list. |
Returns the standard deviation of an iterable.
Example:
>>> sd([1, 4, 7, 11]) #doctest:+ELLIPSIS 4.2720...
Parameters | |
xs | an iterable yielding numbers. |
Returns | |
the standard deviation of the numbers provided by the iterable. | |
See Also | |
RunningMean() if you also need the mean |