-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathsem_01_181.py
65 lines (46 loc) · 1.23 KB
/
sem_01_181.py
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
import numpy as np # массивы
import pandas as pd # таблички с данными
import seaborn as sns # графики
import matplotlib.pyplot as plt
from scipy import special
from scipy.stats import norm, expon, uniform
special.factorial(10)
special.binom(10, 5)
np.random.seed(seed=777) # инициализировали гсч
x = norm.rvs(size=100, loc=10, scale=7)
x
y = uniform.rvs(size=100, loc=5, scale=13)
y
z = [a for a in range(2, 21)]
z
z = [a for a in range(2, 21) if a > 5]
z
gorshok = pd.DataFrame({'gor': norm.rvs(size=100, loc=0, scale=5),
'shok': expon.rvs(size=100, scale=7)})
gorshok.head()
gorshok.describe()
gorshok.cov()
gorshok.corr()
gorshok['dub'] = gorshok['gor'] * gorshok['shok']
gorshok.describe()
sns.distplot(gorshok['gor'])
plt.show()
sns.jointplot(data=gorshok, x='gor', y='shok')
def udav(len_bulki=1):
'''
Симулятор жизни удава Анатолия
Args:
len_bulki: длина булки
Return:
int: число укусов булки
'''
bites = 0
while len_bulki > 0:
len_bulki -= uniform.rvs()
bites += 1
return bites
udav(10)
udav()
terra = [udav(10) for i in range(1000)]
np.mean(terra)
np.var(terra)