2
I’ll be very brief. I’m just wondering how to put in for when the values of the first column of the matrix is less than zero, the values of the second column will be a.
from scipy import stats
from scipy.stats import norm
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
#Exercise 1:
x = np.array([7.3,8.2,6.0,7.7,8.0,6.1,5.6,5.3,5.9,5.8,5.8,7.1,5.1,8.0,7.6,8.3,4.9,6.5])
y = np.array([7.5,6.2,5.7,4.4,4.7,5.8,5.0,6.0,6.5,5.8,4.5,5.1,5.5,6.0,5.8,5.8,5.7,7.5])
m = 100000
matrix = np.zeros((m,2))
matrix
for i in range(0,m):
matrix[i,0] = np.mean(np.random.normal(x)) - np.mean(np.random.normal(y))
if matrix[i,0]<0:
matrix[0,i] = 1
dados = matrix[0: , :1]
sns.distplot(dados)
plt.title("Histograma da Distribuição Amostral da diferença das Médias")
plt.xlabel("Respostas")
plt.ylabel("Frequência")
plt.show()