Coverage for pygeodesy/fstats.py : 99%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
floating point summation. ''' # make sure int/int division yields float quotient, see .basics
# from pygeodesy.basics import isscalar # from .fmath # from pygeodesy.errors import _TypeError # from .fmath _TypeError _1_5, _2_0, _3_0, _4_0, _6_0
# from math import sqrt # pow from .fmath
'''Return the I{total} number of accumulated values (C{int}). '''
'''Accumulate and return the current count.
@see: Method C{fadd}. '''
'''(INTERNAL) Yield each value as C{float}. '''
'''Accumulate and return the current mean.
@see: Method C{fmean}. '''
'''Accumulate and return the current standard deviation.
@see: Method C{fstdev}. '''
'''Accumulate and return the current variance.
@see: Method C{fvariance}. '''
'''U{Cook's<https://www.JohnDCook.com/blog/skewness_kurtosis>} C{RunningStats} computing the running kurtosis, mean, skewness, (sample) variance, standard deviation and Jarque-Bera normality.
@see: L{Fwelford}. ''' '''New L{Fcook} accumulator.
@kwarg xs: Iterable with initial values (C{Scalar}s). @kwarg name: Optional name (C{str}).
@see: Method L{Fcook.fadd}. '''
'''Sum of this and a scalar, an L{Fsum} or an other instance.
@arg other: L{Fcook} instance or a C{Scalar}.
@return: The sum (L{Fcook}).
@see: Methods L{Fcook.__iadd__} and L{Fcook.fadd}. '''
'''Add a scalar, an L{Fsum} or an other instance to this instance.
@arg other: L{Fcook} instance or a C{Scalar}.
@return: This instance, updated (L{Fcook}).
@raise TypeError: Invalid B{C{other}} type.
@see: Method L{Fcook.fadd}. ''' other is self else other._Ms
# self._Ms = A1, A2, A3, A4 else:
elif isinstance(other, _Float) or isscalar(other): self.fadd_(other) else: raise _TypeError(_SPACE_(self, _iadd_, repr(other)))
def __radd__(self, other): # PYCHOK no cover '''Not implemented.''' return _NotImplemented(self, other)
'''Accumulate and return the current count.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}).
@note: C{Scalar} means an L{Fsum} instance or C{scalar}.
@return: Current, running count (C{float}).
@raise OverflowError: Partial C{2sum} overflow.
@raise TypeError: Non-scalar B{C{xs}} value.
@raise ValueError: Invalid or non-finite B{C{xs}} value. ''' else:
'''Copy this instance, C{shallow} or B{C{deep}}.
@return: The copy (L{Fwelford}). '''
'''Accumulate and compute the current U{Jarque-Bera <https://WikiPedia.org/wiki/Jarque–Bera_test>} normality.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} value (C{bool}), default. @kwarg excess: Return the I{excess} kurtosis (C{bool}), default.
@return: Current, running Jarque-Bera normality (C{float}).
@see: Method L{Fcook.fadd}. '''
'''Accumulate and compute the current U{Jarque-Bera <https://WikiPedia.org/wiki/Jarque–Bera_test>} normality.
@see: Method L{Fcook.fjb}. '''
'''Accumulate and return the current kurtosis.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}). @kwarg excess: Return the I{excess} kurtosis (C{bool}), default.
@return: Current, running kurtosis or I{excess} kurtosis (C{float}).
@see: U{Kurtosis Formula<https://www.Macroption.com/kurtosis-formula>} and U{Mantalos<https://www.researchgate.net/publication/ 227440210_Three_different_measures_of_sample_skewness_and_kurtosis_and_their_effects_on_the_JarqueBera_test_for_normality>}.
@see: Method L{Fcook.fadd}. '''
'''Accumulate and return the current kurtosis.
@see: Method L{Fcook.fkurtosis}. '''
'''Accumulate and return the current mean.
@kwarg xs: Iterable with additional values (C{Scalar}s).
@return: Current, running mean (C{float}).
@see: Method L{Fcook.fadd}. ''' self.fadd(xs)
'''Accumulate and return the current median.
@kwarg xs: Iterable with additional values (C{Scalar}s).
@return: Current, running median (C{float}).
@see: U{Pearson's Skewness Coefficients<https://MathWorld.Wolfram.com/ PearsonsSkewnessCoefficients.html>} and U{Skewness & Kurtosis Simplified https://TowardsDataScience.com/skewness-kurtosis-simplified-1338e094fc85>}.
@see: Method L{Fcook.fadd}. ''' # skewness = 3 * (mean - median) / stdev, i.e. # median = mean - skewness * stdef / 3
'''Accumulate and return the current median.
@see: Method L{Fcook.fmedian}. '''
'''Accumulate and return the current skewness.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}).
@return: Current, running skewness (C{float}).
@see: U{Skewness Formula<https://www.Macroption.com/skewness-formula/>} and U{Mantalos<https://www.researchgate.net/publication/ 227440210_Three_different_measures_of_sample_skewness_and_kurtosis_and_their_effects_on_the_JarqueBera_test_for_normality>}.
@see: Method L{Fcook.fadd}. '''
'''Accumulate and return the current skewness.
@see: Method L{Fcook.fskewness}. '''
'''Accumulate and return the current standard deviation.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}).
@return: Current, running standard deviation (C{float}).
@see: Method L{Fcook.fadd}. '''
'''Accumulate and return the current variance.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}).
@return: Current, running variance (C{float}).
@see: Method L{Fcook.fadd}. '''
'''U{Welford's<https://WikiPedia.org/wiki/Algorithms_for_calculating_variance>} accumulator computing the running mean, (sample) variance and standard deviation.
@see: U{Cook<https://www.JohnDCook.com/blog/standard_deviation/>} and L{Fcook}. ''' '''New L{Fwelford} accumulator.
@kwarg xs: Iterable with initial values (C{Scalar}s). @kwarg name: Optional name (C{str}).
@see: Method L{Fwelford.fadd}. '''
'''Return the I{total} number of accumulated values (C{int}). '''
'''Accumulate and return the current count.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}).
@note: C{Scalar} means an L{Fsum} instance or C{scalar}.
@return: Current, running count (C{float}).
@raise OverflowError: Partial C{2sum} overflow.
@raise TypeError: Non-scalar B{C{xs}} value.
@raise ValueError: Invalid or non-finite B{C{xs}} value. '''
'''Copy this instance, C{shallow} or B{C{deep}}.
@return: The copy (L{Fwelford}). '''
'''Accumulate and return the current mean.
@kwarg xs: Iterable with additional values (C{Scalar}s).
@return: Current, running mean (C{float}).
@see: Method L{Fwelford.fadd}. '''
'''Accumulate and return the current standard deviation.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}).
@return: Current, running standard deviation (C{float}).
@see: Method L{Fwelford.fadd}. '''
'''Accumulate and return the current variance.
@kwarg xs: Iterable with additional values (C{Scalar}s). @kwarg sample: Return the I{sample} instead of the full I{population} value (C{bool}).
@return: Current, running variance (C{float}).
@see: Method L{Fwelford.fadd}. '''
# **) MIT License # # Copyright (C) 2021-2022 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. |