Suppose we generate a random variable as follows:
y = np.random.normal(loc=np.random.randint(2),scale=1.2)
Then what is the probability density function(pdf) of y i.e. p(y) in this situation?
Thanks in advance.
Suppose we generate a random variable as follows:
y = np.random.normal(loc=np.random.randint(2),scale=1.2)
Then what is the probability density function(pdf) of y i.e. p(y) in this situation?
Thanks in advance.
This is a mixture of an absolutely continuous distribution (the normal distribution) and a discrete distribution (the uniform distribution). In the case at hand, the distribution has a probability density function (PDF) of the following form:
∑y fy(x) * g(y),
Where—
numpy.random.randint
excludes the endpoint).See also page 16 of Non-Uniform Random Variate Generation.
In this case, the mixture PDF is:
Where N is the PDF for the normal distribution. See also a comment by "jdehesa".
(Note that numpy.random.*
functions, including randint
and normal
, are legacy functions as of NumPy 1.17; see also this question.)