In scipy.stats.norm.rvs()
the argument scale denotes standard deviation but in the below piece of code sigma_list refers to an array. How does the code actually work?
Where sigma_list is obtained by following code:
sigma=0.06
mask=(x > 0.65) & (x < 0.8)
sigma_list=sigma+mask*0.03
sigma_list
y = sp.stats.norm.rvs(scale=sigma_list, size=200)
Even the standard deviations of both sigma_list and y are also not matching
I want to know the working of the above scipy module
sorry, i didn't mention that x is an array of values between 0 and 1
In your code, the mask
will be either True or False here. So if you do some addition or subtraction, it is respectively translated into 1 or 0.
Then the result of sigma_list
is not a list nor an array but a floating value. Looking at the documentation, you can see its usage.
rvs(loc=0, scale=1, size=1, random_state=None)
If you look at the code (line 2771) you have:
loc : array_like, optional Location parameter (default=0).
size : int or tuple of ints, optional Defining number of random variates (Default is 1). Note that
size
has to be given as keyword, not as positional argument.random_state : None or int or
np.random.RandomState
instance, optional If int or RandomState, use it for drawing the random variates. If None, rely onself.random_state
. Default is None.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With