39

numpy.randomモジュールは、連続一様分布から [0, 1.0) の間の浮動小数点数を返すように見える次の 4 つの関数を定義しますこれらの機能の違いは何ですか?

random_sample([size]) 半開区間 [0.0, 1.0) のランダム浮動小数点数を返します。

random([size]) 半開区間 [0.0, 1.0) のランダム浮動小数点数を返します。

ranf([size]) 半開区間 [0.0, 1.0) のランダム浮動小数点数を返します。

sample([size]) 半開区間 [0.0, 1.0) のランダム浮動小数点数を返します。

--------------------------- フォローを編集 ---------------------- ------------------

numpy.random@askewchanの回答をサポートするソースコードで次を見つけました:

# Some aliases:
ranf = random = sample = random_sample
__all__.extend(['ranf','random','sample'])
4

2 に答える 2

51

何もない。

それらは単なるエイリアスですrandom_sample

In [660]: np.random.random
Out[660]: <function random_sample>

In [661]: np.random.ranf
Out[661]: <function random_sample>

In [662]: np.random.sample
Out[662]: <function random_sample>

In [663]: np.random.random_sample is np.random.random
Out[663]: True

In [664]: np.random.random_sample is np.random.ranf
Out[664]: True

In [665]: np.random.random_sample is np.random.sample
Out[665]: True
于 2013-09-16T13:33:50.813 に答える