Files
applied-statistics/theory/notes.typ
2025-12-23 12:25:41 +03:00

146 lines
4.3 KiB
Typst

#show math.equation: set text(size: 12pt, weight: "light", top-edge: "ascender", bottom-edge: "descender")
#set page(
paper: "a4",
margin: (x: 1.8cm, y: 1.5cm),
)
#set text(
font: "New Computer Modern",
size: 12pt,
lang: "ru",
weight: "light"
)
#set par(
// first-line-indent: (
// amount: 1.5em,
// all: true
//),
justify: true,
leading: 0.52em,
)
#show raw.where(block: false): box.with(
fill: luma(240),
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
)
#show raw.where(block: true): block.with(
fill: luma(240),
inset: 10pt,
radius: 4pt,
)
#align(center)[= Распределения]
#align(center)[
#figure(
table(columns: 5, align: horizon, inset: 10pt)[*Распределение*][*Формула*][*$E[X]$*][*$V a r(X)$*][*Оценки*][Бернулли][$p^k (1 - p)^(1 - k)$][$p$][$p(1 - p)$][$p eq overline(X) \ theta_1 eq theta_2 eq overline(X) \ theta eq overline(X)$][Экспоненциальное][$cases(lambda e^(-lambda x) space.quad &x gt.eq 0, 0 space.quad &x lt 0)$][$1/lambda$][$1/(lambda^2)$][$theta_k eq sqrt(frac(k!, overline(X^k))) \ theta eq 1/overline(X)$][Равномерное][$cases(frac(1, b - a) space.quad &a lt.eq x lt.eq b, 0 space.quad &x lt a " или " x gt b)$][$frac(a + b, 2)$][$frac((b - a)^2, 12)$][$a eq 2 overline(X) - b$][Пуассона][$frac(lambda^k e^(-lambda), k!)$][$lambda$][$lambda$][$lambda eq overline(X)$][Биномиальное][$binom(n, k) p^k (1 - p)^(n - k)$][$n p$][$n p (1 - p)$][$p eq frac(overline(X), n) \ theta eq 1 - frac(S^2, overline(x)) \ theta eq frac(overline(X), m)$][Нормальное][][$a$][$sigma^2$][$a eq overline(X)$][Геометрическое][$(1 - p)^(k - 1) p$][$1/p$][$frac(1 - p, p^2)$][$p eq frac(1, overline(X)) \ theta_1 eq frac(1, overline(X)) \ theta_2 eq frac(-1 + sqrt(1 + 8 overline(X^2)), 2 overline(X^2)) \ theta eq frac(1, overline(X))$],
supplement: [Табл.],
caption: [Виды распределений и их параметры.]
)
]
#align(center)[= Построение гистограммы]
```py
import numpy as np
import matplotlib.pyplot as plt
def main() -> None:
data = np.array([v for v in open("data.csv", 'r')])
plt.figure()
plt.hist(data, bins = 10, edgecolor='black', justify=True)
plt.show() # показать гистограмму
a, b = np.histogram(data, bins=10)
print(a) # количество элементов в каждом промежутке
if __name__ == "__main__":
main()
```
#align(center)[= Нахождение параметров выборки]
```py
import numpy as np
def main() -> None:
data = np.array([v for v in open("data.csv", 'r')])
print(data.mean())
print(data.var(ddof=1)) # поделенное на (n - 1) (несмещенное)
print(data.var(ddof=0)) # смещенное
if __name__ == "__main__":
main()
```
#align(center)[= Нормальное/Гауссово распределение]
```py
np.random.normal(loc, scale, size)
# loc - (mean) where the peak of the bell exists.
# scale - (standard deviation) how flat the graph distribution should be.
# size - the shape of the returned array.
```
#align(center)[= Биномиальное распределение]
```py
np.random.binomial(n, p, size)
# n - number of trials.
# p - probability of occurrence of each trial (e.g. for toss of a coin 0.5 each).
# size - the shape of the returned array.
```
#align(center)[= Распределение Пуассона]
```py
np.random.poisson(lam, size)
# lam - rate or known number of occurrences e.g. 2 for above problem.
# size - the shape of the returned array.
```
#align(center)[= Равномерное распределение]
```py
np.random.uniform(low, high, size)
# low - lower bound - default 0.0
# high - upper bound - default 1.0
# size - The shape of the returned array
```
#align(center)[= Экспоненциальное/показательное распределение]
```py
np.random.exponential(scale, size)
# scale - inverse of rate ( see lam in poisson distribution ) defaults to 1.0
# size - The shape of the returned array
```
#align(center)[= Геометрическое распределение]
```py
np.random.geometric(p, size)
# p (float): Probability of success (0 < p ≤ 1)
# size (int or tuple, optional): output shape. if None, returns a single value.
```