简体   繁体   中英

generating one random value of a pareto distribution in scipy

My code is as follows:

from scipy.stats import pareto

values=[0.001,0.1,0.0000000000000000000000000000000019,2.,3.,4.,5.,6.,7.,8.,9.,20.,40.,80.,160.]
for b in values:
    par = pareto.rvs(b,loc=0,scale=1, size=1)
    print(par[0])

This is the output:

2.4710696399005953e+244
4457.919153166827
inf
1.074371220057211
1.813450580334762
1.129136768422894
1.0493631839305024
1.0741561671750386
1.1357715848324075
1.3165771298337223
1.000756684137126
1.0001559590523508
1.0831688633464842
1.0001668159923398
1.006863649128853
/usr/local/lib/python3.6/dist-packages/scipy/stats/_continuous_distns.py:5414: RuntimeWarning: overflow encountered in power
  return pow(1-q, -1.0/b)

This is not what I expected. I thought a pareto distribution gives me values near a given value with a 80/20 chance of lying below/over the given value. I also experimented a bit with the variables loc and scale but did not come to a good result.

Can you please point out where I am wrong in my assumptions or the way I use the scipy pareto module?

I ended up generating a pareto value for 1 and multiplying this with the given value. Parameter scale I set to 0.2.

from scipy.stats import pareto

values=[0.001,0.1,0.0000000000000000000000000000000019,2.,3.,4.,5.,6.,7.,8.,9.,20.,40.,80.,160.]
for b in values:
    par = pareto.rvs(1,loc=0,scale=0.2, size=1)
    par=par*b
    print(par[0])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM