python predict y和x是必须一致吗_数据科学python错误 - ValueError:x和y必须具有相同的第一维...
對于背景,我計算了一組sample_means,每個樣本大小200次。然后,我計算每個樣本大小的平均值和標準偏差,然后將其存儲在數(shù)組中。這是我的代碼:
in[] =
sample_sizes = np.arange(1,1001,1)
number_of_samples = 200
mean_of_sample_means = []
std_dev_of_sample_means = []
for x in range (number_of_samples):
mean_of_sample_means.append(np.mean(sample_sizes))
std_dev_of_sample_means.append(np.std(sample_sizes))
in[] = # mean and std of 200 means from 200 replications, each of size 10
trials[0], mean_of_sample_means[0], std_dev_of_sample_means[0]
out[] = (10, 500.5, 288.67499025720952)
現(xiàn)在我想要繪制具有以下輸入數(shù)據(jù):
plt.plot(sample_sizes, mean_of_sample_means);
plt.ylim([0.480,0.520]);
plt.xlabel("sample sizes")
plt.ylabel("mean probability of heads")
plt.title("Mean of sample means over 200 replications");
然而,當我這樣做,我拋出了以下錯誤:
242 if x.shape[0] != y.shape[0]:
243 raise ValueError("x and y must have same first dimension, but "
--> 244 "have shapes {} and {}".format(x.shape, y.shape))
245 if x.ndim > 2 or y.ndim > 2:
246 raise ValueError("x and y can be no greater than 2-D, but have "
ValueError: x and y must have same first dimension, but have shapes (1000,) and (200,)
關于我要去哪里的錯誤?我覺得它可能很明顯,我沒有看到,因為我是新手。任何幫助,將不勝感激!!
+0
嗨,你能嘗試編輯代碼,以實際代碼你用來生成'ValueError'?包括所有模塊導入和變量定義(例如'trials' does not exist) –
+1
我認為相同,但我認為從筆記本粘貼的OP副本 –
+0
我認為你的'mean_of sample_means'將有一個常數(shù)條目500.5所有200人。與'std_dev_of_sample_means'相同,它將成為288.67499025720952 –
總結
以上是生活随笔為你收集整理的python predict y和x是必须一致吗_数据科学python错误 - ValueError:x和y必须具有相同的第一维...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ssms 缺少索引信息_MySQL3:索
- 下一篇: python中的os abort_Pyt