numpyのrandomモジュールのいくつかの一般的な関数
2649 ワード
詳細なrandomモジュールの他の関数:http://www.mamicode.com/info-detail-507676.html rand(d 0,d 1,...,dn)は、いくつかのパラメータを入力して数次元の配列を返し、配列中の要素は0-1のランダム値である. randint(low[,high,size])はランダムな整数を返し、半開区間にある[low,high]. random_integers(low[,high,size])は、閉区間[low,high]に位置するランダムな整数を返します. random([size])はランダムな浮動小数点数を返し、半開区間[0.0,1.0)である. arrayポイント乗算*は、同じサイズの配列タイプでのみ発生し、応答位置を乗算します.arrayでマトリクス乗算をシミュレートするには、関数dotを呼び出す必要がある.

matrixは2次元のarrayなので、その点乗は行列乗算であってもよい.
>>> np.random.rand(3,2)
array([[ 0.14022471, 0.96360618], #random
[ 0.37601032, 0.25528411], #random
[ 0.49313049, 0.94909878]]) #random
>>> np.random.randint(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0])
>>> np.random.randint(5, size=(2, 4))
array([[4, 0, 2, 1],
[3, 2, 2, 0]])



