Some minor statistics.NormalDist adjustments (#13626)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Joren Hammudoglu
2025-03-15 20:07:47 +01:00
committed by GitHub
parent 5ba2e4989e
commit 8064d995e7
+14 -15
View File
@@ -3,7 +3,7 @@ from _typeshed import SupportsRichComparisonT
from collections.abc import Callable, Hashable, Iterable, Sequence
from decimal import Decimal
from fractions import Fraction
from typing import Any, Literal, NamedTuple, SupportsFloat, TypeVar
from typing import Literal, NamedTuple, SupportsFloat, SupportsIndex, TypeVar
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -38,6 +38,9 @@ _NumberT = TypeVar("_NumberT", float, Decimal, Fraction)
# Used in mode, multimode
_HashableT = TypeVar("_HashableT", bound=Hashable)
# Used in NormalDist.samples and kde_random
_Seed: TypeAlias = int | float | str | bytes | bytearray # noqa: Y041
class StatisticsError(ValueError): ...
if sys.version_info >= (3, 11):
@@ -89,7 +92,7 @@ class NormalDist:
def variance(self) -> float: ...
@classmethod
def from_samples(cls, data: Iterable[SupportsFloat]) -> Self: ...
def samples(self, n: int, *, seed: Any | None = None) -> list[float]: ...
def samples(self, n: SupportsIndex, *, seed: _Seed | None = None) -> list[float]: ...
def pdf(self, x: float) -> float: ...
def cdf(self, x: float) -> float: ...
def inv_cdf(self, p: float) -> float: ...
@@ -98,15 +101,15 @@ class NormalDist:
if sys.version_info >= (3, 9):
def zscore(self, x: float) -> float: ...
def __eq__(self, x2: object) -> bool: ...
def __add__(self, x2: float | NormalDist) -> NormalDist: ...
def __sub__(self, x2: float | NormalDist) -> NormalDist: ...
def __mul__(self, x2: float) -> NormalDist: ...
def __truediv__(self, x2: float) -> NormalDist: ...
def __pos__(self) -> NormalDist: ...
def __neg__(self) -> NormalDist: ...
def __eq__(x1, x2: object) -> bool: ...
def __add__(x1, x2: float | NormalDist) -> NormalDist: ...
def __sub__(x1, x2: float | NormalDist) -> NormalDist: ...
def __mul__(x1, x2: float) -> NormalDist: ...
def __truediv__(x1, x2: float) -> NormalDist: ...
def __pos__(x1) -> NormalDist: ...
def __neg__(x1) -> NormalDist: ...
__radd__ = __add__
def __rsub__(self, x2: float | NormalDist) -> NormalDist: ...
def __rsub__(x1, x2: float | NormalDist) -> NormalDist: ...
__rmul__ = __mul__
def __hash__(self) -> int: ...
@@ -153,9 +156,5 @@ if sys.version_info >= (3, 13):
data: Sequence[float], h: float, kernel: _Kernel = "normal", *, cumulative: bool = False
) -> Callable[[float], float]: ...
def kde_random(
data: Sequence[float],
h: float,
kernel: _Kernel = "normal",
*,
seed: int | float | str | bytes | bytearray | None = None, # noqa: Y041
data: Sequence[float], h: float, kernel: _Kernel = "normal", *, seed: _Seed | None = None
) -> Callable[[], float]: ...