#author("2018-07-25T23:20:47+09:00","default:Miyashita","Miyashita")
#author("2018-07-25T23:21:08+09:00","default:Miyashita","Miyashita")
*Python演習問題:乱数とソート [#lbb80cc3]
***インポート・エイリアス設定 [#z9fd9d7e]
#codeprettify(lang-python){{
import numpy as np
import matplotlib.pyplot as plt
}}
***問題 [#y4bcdf17]
+0から100までの範囲で,100個の乱数列(整数)を作成し,その分布を調べなさい.
#codeprettify(lang-python){{
np.random.randint
fig = plt.figure()
ax = fig.subplot(111)
ax.bar(varname)
}}

+作成した乱数列データの平均値と標準偏差を求めなさい.
#codeprettify(lang-python){{
np.mean
np.std
}}

+作成した乱数列データから上位5位の値を求め,乱数列のどの位置にあるのか図で示しなさい.
#codeprettify(lang-python){{
np.argsort(XX)[::-1]
}}

***解答例(参考) [#tf775f30]
平均値を緑の実線として描いた.また,ギリシャ文字を挿入する練習としてタイトル位置に標準偏差を表してみた.
#ref(https://main-t-miyashita.ssl-lolipop.jp/hydrocoast/image/python/rand_and_hist.png)

Front page   Edit Diff Attach Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes