mercredi 24 août 2016

Can you "force" `scipy.stats.norm.rvs` to output positive values?

This may be a naive question but I couldn't find any posts about it so I thought it may be useful to ask. I found a distribution that may fit my data well but all of my data points are positive in real life (- ones are impossible).

Is there a way to force .rvs to output only positive values?

I thought of some ways but they seem pretty CPU intensive like making way more values than I would need and then doing a boolean mask for all the values that are positive and np.random.choice from those. Is there a better way?

I didn't see anything about it in the docs :/ about this: http://ift.tt/1jxi161

My phrases to find this didn't yield any results: http://ift.tt/2bOOao3 and http://ift.tt/2bHoP1M

params = (0.00169906712999, 0.00191866845411)
np.random.seed(0)
stats.norm.rvs(*params, size=10)
array([ 0.0050837 ,  0.00246684,  0.00357694,  0.0059986 ,  0.00528229,
       -0.00017601,  0.00352197,  0.00140866,  0.00150102,  0.00248687])




Aucun commentaire:

Enregistrer un commentaire