前提
統計量G1のeCDF(経験的累積分布関数)グラフを描きたい。
しかし、np.sortを使ってもうまくいかない
実現したいこと
統計量G1のeCDF(経験的累積分布関数)グラフを描きたい
発生している問題・エラーメッセージ
ValueError Traceback (most recent call last) Cell In [42], line 23 21 x_sort = np.sort(G1) 22 ecdf = np.arange(1, n[i]+1) / n[i] ---> 23 plt.plot(G1, ecdf, drawstyle='steps-pre') 24 xx = np.linspace(-2, 2, 100) 25 norm_cdf = norm.cdf(xx) packages\matplotlib\pyplot.py:2728, in plot(scalex, scaley, data, *args, **kwargs) 2726 @_copy_docstring_and_deprecators(Axes.plot) 2727 def plot(*args, scalex=True, scaley=True, data=None, **kwargs): -> 2728 return gca().plot( 2729 *args, scalex=scalex, scaley=scaley, 2730 **({"data": data} if data is not None else {}), **kwargs) ... 506 if x.ndim > 2 or y.ndim > 2: 507 raise ValueError(f"x and y can be no greater than 2D, but have " 508 f"shapes {x.shape} and {y.shape}") ValueError: x and y must have same first dimension, but have shapes (10000,) and (10,)
該当のソースコード
python
1n = [10, 20, 30, 50, 100, 300, 500, 1000] #樣本數 2N =10000 #實驗次數 3alfa = 0.05 4for i in range(len(n)): 5 if i < 1 or i == 7: 6 print(i) 7 # eCDF 8 x_sort = np.sort(G1) 9 ecdf = np.arange(1, n[i]+1) / n[i] 10 plt.plot(G1, ecdf, drawstyle='steps-pre') 11 xx = np.linspace(-2, 2, 100) 12 norm_cdf = norm.cdf(xx) 13 plt.plot(xx, norm_cdf, linestyle = '--', lw=5, color='r', alpha=0.5) 14 plt.show()
。
質問に記載のエラーメッセージよりも上に「Traceback」と書かれてたら、そこから下をできるだけ省略せずに質問に記載してください
(ここに書くのではなく、質問を編集して追記する)
ユーザー名等の個人情報は伏せ字でいいですが、それ以外はできるだけそのまま記載してください

回答1件
あなたの回答
tips
プレビュー