-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathstatistics.pyi
161 lines (138 loc) · 5.46 KB
/
statistics.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import sys
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_extensions import Self, TypeAlias
__all__ = [
"StatisticsError",
"fmean",
"geometric_mean",
"mean",
"harmonic_mean",
"pstdev",
"pvariance",
"stdev",
"variance",
"median",
"median_low",
"median_high",
"median_grouped",
"mode",
"multimode",
"NormalDist",
"quantiles",
]
if sys.version_info >= (3, 10):
__all__ += ["covariance", "correlation", "linear_regression"]
if sys.version_info >= (3, 13):
__all__ += ["kde", "kde_random"]
# Most functions in this module accept homogeneous collections of one of these types
_Number: TypeAlias = float | Decimal | Fraction
_NumberT = TypeVar("_NumberT", float, Decimal, Fraction)
# Used in mode, multimode
_HashableT = TypeVar("_HashableT", bound=Hashable)
class StatisticsError(ValueError): ...
if sys.version_info >= (3, 11):
def fmean(data: Iterable[SupportsFloat], weights: Iterable[SupportsFloat] | None = None) -> float: ...
else:
def fmean(data: Iterable[SupportsFloat]) -> float: ...
def geometric_mean(data: Iterable[SupportsFloat]) -> float: ...
def mean(data: Iterable[_NumberT]) -> _NumberT: ...
if sys.version_info >= (3, 10):
def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = None) -> _NumberT: ...
else:
def harmonic_mean(data: Iterable[_NumberT]) -> _NumberT: ...
def median(data: Iterable[_NumberT]) -> _NumberT: ...
def median_low(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ...
def median_high(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ...
if sys.version_info >= (3, 11):
def median_grouped(data: Iterable[SupportsFloat], interval: SupportsFloat = 1.0) -> float: ...
else:
def median_grouped(data: Iterable[_NumberT], interval: _NumberT | float = 1) -> _NumberT | float: ...
def mode(data: Iterable[_HashableT]) -> _HashableT: ...
def multimode(data: Iterable[_HashableT]) -> list[_HashableT]: ...
def pstdev(data: Iterable[_NumberT], mu: _NumberT | None = None) -> _NumberT: ...
def pvariance(data: Iterable[_NumberT], mu: _NumberT | None = None) -> _NumberT: ...
def quantiles(
data: Iterable[_NumberT], *, n: int = 4, method: Literal["inclusive", "exclusive"] = "exclusive"
) -> list[_NumberT]: ...
def stdev(data: Iterable[_NumberT], xbar: _NumberT | None = None) -> _NumberT: ...
def variance(data: Iterable[_NumberT], xbar: _NumberT | None = None) -> _NumberT: ...
class NormalDist:
def __init__(self, mu: float = 0.0, sigma: float = 1.0) -> None: ...
@property
def mean(self) -> float: ...
@property
def median(self) -> float: ...
@property
def mode(self) -> float: ...
@property
def stdev(self) -> float: ...
@property
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 pdf(self, x: float) -> float: ...
def cdf(self, x: float) -> float: ...
def inv_cdf(self, p: float) -> float: ...
def overlap(self, other: NormalDist) -> float: ...
def quantiles(self, n: int = 4) -> list[float]: ...
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: ...
__radd__ = __add__
def __rsub__(self, x2: float | NormalDist) -> NormalDist: ...
__rmul__ = __mul__
def __hash__(self) -> int: ...
if sys.version_info >= (3, 12):
def correlation(
x: Sequence[_Number], y: Sequence[_Number], /, *, method: Literal["linear", "ranked"] = "linear"
) -> float: ...
elif sys.version_info >= (3, 10):
def correlation(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ...
if sys.version_info >= (3, 10):
def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ...
class LinearRegression(NamedTuple):
slope: float
intercept: float
if sys.version_info >= (3, 11):
def linear_regression(
regressor: Sequence[_Number], dependent_variable: Sequence[_Number], /, *, proportional: bool = False
) -> LinearRegression: ...
elif sys.version_info >= (3, 10):
def linear_regression(regressor: Sequence[_Number], dependent_variable: Sequence[_Number], /) -> LinearRegression: ...
if sys.version_info >= (3, 13):
_Kernel: TypeAlias = Literal[
"normal",
"gauss",
"logistic",
"sigmoid",
"rectangular",
"uniform",
"triangular",
"parabolic",
"epanechnikov",
"quartic",
"biweight",
"triweight",
"cosine",
]
def kde(
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
) -> Callable[[], float]: ...