生成父母平均身高和孩子身高是否1.8的测试数据

需要了解:生成父母平均身高和孩子身高的测试数据

import numpy as np
import matplotlib.pyplot as plt

parent_height=np.linspace(1.5,1.9,1000)
children_height=0.8567+0.516*parent_height
children_height2=np.random.normal(children_height,0.01)

plt.scatter(parent_height,children_height2)
parent_children_height=np.dstack((parent_height,children_height2))
print(parent_children_height.shape)

csv_height=parent_children_height.reshape(parent_children_height.shape[1],parent_children_height.shape[2])
print(csv_height.shape)
csv_height[:,1][csv_height[:,1]<1.8]=0
csv_height[:,1][csv_height[:,1]>=1.8]=1
np.savetxt('父母平均身高和孩子身高是否1.8.csv',csv_height,fmt='%f',delimiter=',')
csv_height

原文出处:/show_1EF4IF3reQsr.html