Reputation: 147
In scipy.stats most of distribution have rvs method, which provides random samples. But I didn't find explanation random samples of what? probability? No, because it more than 1.
Upvotes: 6
Views: 28980
Reputation: 21663
By default, invoking an rvs method once produces a single value of a pseudorandom variable, not a pseudorandom sample. For instance, here we see the results of a series of invocations of the rvs method for the beta distribution with shape parameters 1 and 3.
>>> from scipy.stats import beta
>>> beta.rvs(1,3)
0.11573182734943342
>>> beta.rvs(1,3)
0.711001211281741
>>> beta.rvs(1,3)
0.13358246108665714
If it's necessary to repeat a series of pseudorandom values for this distribution then the random_state parameter can be used, as indicated here.
>>> beta.rvs(1,3,random_state=1)
0.2570633444085756
>>> beta.rvs(1,3)
0.006105422238509487
>>> beta.rvs(1,3)
0.03773135132269083
>>> beta.rvs(1,3,random_state=1)
0.2570633444085756
>>> beta.rvs(1,3)
0.006105422238509487
>>> beta.rvs(1,3)
0.03773135132269083
Clarification (I hope):
The full signature for beta.rvs
is:
rvs(a, b, loc=0, scale=1, size=1, random_state=None)
When I first wrote that this method produces a single value of a pseudorandom variable, I should have indicated that this would be by default, since size=1
. That is, the method produces a sample of size one by default. The method is obviously capable of producing larger (pseudo-)random samples by setting its size
parameter to values greater than one.
Upvotes: 8