randn関数【numpy】
説明:正規分布に基づく乱数を返す関数。
書式:
numpy.random.randn(引数1,引数2、... )
引数:可変長引数であり、先頭から順に高次の次元のサイズを指定する。
戻り値:
引数の個数が0:float型(配列ではない)
引数が与えられた場合は、それらで指定された形状の配列
code:randn1.py
import numpy as np
print('引数無し-----------------')
x = np.random.randn()
print(type(x)) # float型はshape属性を持たない
print(x)
print('引数が1つ-----------------')
x = np.random.randn(4)
print(type(x), x.shape)
print(x)
print('引数が2つ-----------------')
x = np.random.randn(4, 3)
print(type(x), x.shape)
print(x)
print('引数が3つ-----------------')
x = np.random.randn(4, 3, 2)
print(type(x), x.shape)
print(x)
関連:shape属性【numpy】
https://scrapbox.io/files/65044c83286efb001baa8a59.png