GH_J5
/
ADA1
27 строк · 821.0 Байт
1import mat4py
2import numpy as np
3from matplotlib import pyplot as plt
4from scipy import stats
5
6input = mat4py.loadmat('Data.mat')
7data = np.array(input['X'])
8validation_set_x = np.array(input['Xval'])
9validation_set_y = np.array(input['yval'])
10
11
12'' 'Подберите данные с положительным распределением' ''
13mu = sum(data)/len(data[:,0])
14sigma2 = []
15for i in range(len(data[0,:])):
16Sum = 0
17for j in range(len(data[:,0])):
18Sum += (data[j,i]-mu[i])**2
19sigma2.append(Sum/len(data[:,0]))
20
21v_mu = sum(validation_set_x)/len(validation_set_x[:,0])
22v_sigma2 = []
23for i in range(len(validation_set_x[0,:])):
24Sum = 0
25for j in range(len(validation_set_x[:,0])):
26Sum += (validation_set_x[j,i]-v_mu[i])**2
27v_sigma2.append(Sum/len(validation_set_x[:,0]))