# 随机生成（x,y）数据值，并画出散点图

## 随机生成（x,y）数据值，并画出散点图

import numpy as np
import matplotlib.pyplot as plt
r = []#生成两个空列表
b = []
d=np.zeros((50,2))
print(d)
Mean=0
STD=5
for i in range(50):
x=np.random.uniform(1,10)#1-10之间抽样随机数
d[i,0] = x
r.append(x)
#  noise=np.random.normal(Mean,STD)
y=(3*x+2)+np.random.normal(Mean,STD)
b.append(y)
d[i,1] = y
plt.plot(x, y, marker='o')
print(r,b)
print(d.size)
print(d.shape)

[[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]]
[9.69215307179715, 8.03878826981242, 8.379231701178885, 7.283337794776486, 8.042167554175512, 2.548212541222832, 4.46062013302644, 5.994285954218048, 3.4094013255795503, 7.65419266855716, 6.334312640517438, 1.9223784248019695, 6.521998695717684, 6.421536094931474, 9.484853937693865, 3.8141778173112693, 1.8517117717181315, 1.0442746566778465, 4.559522144646644, 5.055351223227683, 5.641510301105903, 4.90854620936207, 9.108042146650053, 1.7363494437736688, 9.637726549686974, 5.524804530989425, 4.142447426011121, 5.767207825050692, 2.4809094847151147, 1.6702035699070101, 8.858705448269127, 6.186779987910564, 4.987311499394078, 5.918118242709069, 3.3663622820461487, 3.3437891886400735, 5.0405854612130385, 7.805432206145205, 2.578054105016733, 6.245578853884911, 4.859921802388921, 6.140526028730131, 6.409513897021853, 3.066514135116905, 2.357064131179057, 3.445452304526637, 8.26390974680585, 5.41844929586708, 5.84338783092134, 1.5577111864655193] [27.054650214583212, 23.71081061528119, 33.654885025473696, 17.24563040554478, 27.114947368980605, 9.327325981294969, 20.374800489892415, 15.929797758820989, 16.395379919616037, 25.899395946800333, 22.523249690652968, 11.979279710422645, 19.627516302048292, 23.459024452893367, 30.823712818155723, 5.650315474514121, 9.619110903762827, 10.848871995212727, 12.983611148272908, 12.722010256792824, 14.188346397531499, 15.35642785174343, 30.057773494934015, 10.27515170880057, 25.804899574519784, 26.622520394203868, 22.941413157007855, 22.690871022210718, 13.408738920507616, 3.0967685703006342, 32.76428136196499, 12.320366002088127, 19.03487845427546, 24.77312935188126, 19.21050483070527, 15.678475692043024, 33.801510165263345, 34.25193252466346, 6.213783666279897, 35.63463364702152, 14.526077051328611, 19.654288310573044, 21.39820537395082, 18.984177799627798, 9.812218711050956, 13.102391731065856, 20.607743461765438, 20.018063517688397, 18.19478470463024, 4.81095164780705]
(50, 2)