Posto a resolução do meu exercício, para verificar se está ok. Obtive o mesmo coeficiente para as laranjas e toranjas, não sei se está certo.
#Laranjas
np.random.uniform(low=1.00, high=5.00, size= 5000)
coef_angulares = np.random.uniform(low=1.00, high=5.00, size= 100)
b = 17
laranja = np.array([])
np.random.seed(16)
for i in range(100):
laranja = np.append(laranja, np.linalg.norm(Y -(coef_angulares [i]*X+b)))
laranja
array([8546.32107831, 7819.71559427, 7752.99007049, 8976.87646141,
8213.30087324, 8546.83025637, 7418.55490977, 8690.63859378,
8916.97057535, 6807.27691478, 7721.53944494, 8898.39160284,
7336.38068276, 8703.43063811, 8480.92188014, 8376.2310633 ,
7399.45067477, 7962.43034762, 8566.26038001, 8004.68285971,
8794.47411282, 6863.78926041, 7714.83992095, 7943.63915313,
8325.15496409, 8982.65849512, 7264.16501445, 7770.99897464,
7228.4369173 , 7172.08248028, 8912.37515498, 7488.84690838,
8958.22497904, 7427.52413855, 8013.10364903, 7953.38743296,
7485.59160454, 7415.54925546, 8449.3052729 , 9059.55976031,
7218.49295822, 7109.82769935, 8749.01016586, 7686.82882062,
8261.89415889, 8524.69660583, 8606.04334477, 8429.52993583,
6720.43432899, 8565.37151331, 8223.77189726, 9042.78948056,
7592.85581239, 8529.08260455, 7288.62063313, 7671.70080655,
8069.43308414, 7368.81890573, 6732.08193248, 7124.61559064,
8043.86604727, 6766.77088463, 8971.65190785, 7311.80845539,
7450.19856171, 7810.40674755, 7713.52876918, 7335.64230552,
7433.39046343, 7160.29734105, 8813.9393066 , 8604.78606333,
7339.58213564, 8133.00466595, 8265.50177071, 8715.56175679,
8843.67422163, 8100.5848277 , 7674.93491267, 7292.5730437 ,
6978.45823945, 6745.45497867, 7983.50891151, 8117.11995405,
8363.01962359, 7080.22450634, 6882.79930236, 7230.9901338 ,
8921.8411863 , 7618.93649716, 6811.62543156, 8839.87326383,
6718.77037614, 8223.09027475, 7502.24288015, 8789.8534014 ,
6757.99115514, 7509.52580101, 6817.77563469, 6885.25584304])
coef_angulares[0]
1.8931643166141554
#toranjas
coef_angulares = np.random.uniform(low=1.00, high=5.00, size= 100)
toranja = np.array([])
np.random.seed(16)
for i in range(100):
toranja = np.append(toranja, np.linalg.norm(Z -(coef_angulares [i]*W+b)))
toranja
array([11275.87543134, 10296.95379605, 10207.05674336, 11855.93551235,
10827.21489671, 11276.56141763, 9756.48096461, 11470.30583549,
11775.22837144, 8932.90947218, 10164.68431775, 11750.19816329,
9645.76907836, 11487.53976941, 11187.76679616, 11046.72253878,
9730.74219133, 10489.22805288, 11302.7384997 , 10546.15315066,
11610.19691754, 9009.04901589, 10155.65825786, 10463.91141851,
10977.91036684, 11863.72525005, 9548.47394234, 10231.31954973,
9500.33790331, 9424.41212528, 11769.03726943, 9851.18391019,
11830.80764318, 9768.56503107, 10557.49813186, 10477.0448925 ,
9846.79811159, 9752.4315046 , 11145.17148944, 11967.32897948,
9486.94051567, 9340.5367014 , 11548.94622723, 10117.91975719,
10892.68226727, 11246.74201754, 11356.33575586, 11118.52925693,
8815.90541125, 11301.54098122, 10841.32200423, 11944.73555891,
9991.31257401, 11252.65102355, 9581.42267288, 10097.53823326,
10633.38839007, 9689.47255812, 8831.59839181, 9360.46033869,
10598.94301883, 8878.33526191, 11848.89682876, 9612.66329381,
9799.11382291, 10284.41230975, 10153.89178374, 9644.77427443,
9776.468614 , 9408.53410484, 11636.42112185, 11354.64189494,
9650.08234473, 10719.03556176, 10897.54262437, 11503.88327496,
11676.48104324, 10675.35776824, 10101.89544907, 9586.74770072,
9163.54295308, 8849.61607634, 10517.62635554, 10697.63480629,
11028.92346052, 9300.65246573, 9034.66136229, 9503.77782333,
11781.79021873, 10026.45037883, 8938.76827033, 11671.36026068,
8813.66354347, 10840.40368708, 9869.232001 , 11603.97172869,
8866.50622606, 9879.04411308, 8947.05449596, 9037.97107327])
coef_angulares[0]
1.8931643166141554