方法
random.RandomState.
power
提取样本 [0, 1] 从正指数a-1的幂分布。
也称为功率函数分布。
注解
新代码应该使用 power A方法 default_rng() 请参阅 快速启动 .
default_rng()
分布的参数。必须为非负。
输出形状。如果给定的形状是,例如, (m, n, k) 然后 m * n * k 取样。如果尺寸是 None (默认),如果 a 是标量。否则, np.array(a).size 取样。
(m, n, k)
m * n * k
None
a
np.array(a).size
从参数化功率分布中提取样本。
如果A<1。
参见
Generator.power
应该用于新代码。
笔记
概率密度函数是
System Message: WARNING/2 (p(x;a)=a x ^ a-1,0\le x\le 1,a>0。)
latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2018-12-01> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2018/09/03 v1.4i Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character ; (U+FF1B) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character 。 (U+3002) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character ; (U+FF1B) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} ! Package inputenc Error: Unicode character 。 (U+3002) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ... x ^ a-1,0\le x\le 1,a>0。\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 416 bytes). Transcript written on math.log.
幂函数分布与帕累托分布正好相反。它也可以看作是β分布的一个特殊情况。
例如,它用于建模保险索赔的超额报告。
工具书类
Christian Kleiber,Samuel Kotz,“经济学和精算科学中的统计规模分布”,Wiley,2003年。
Heckert,N.A.和Filliben,James J.,“NIST手册148:数据图参考手册,第2卷:LET子命令和类库功能”,国家标准技术研究所手册系列,2003年6月。https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/powdpdf.pdf
实例
从分发中抽取样本:
>>> a = 5. # shape >>> samples = 1000 >>> s = np.random.power(a, samples)
显示样本的直方图,以及概率密度函数:
>>> import matplotlib.pyplot as plt >>> count, bins, ignored = plt.hist(s, bins=30) >>> x = np.linspace(0, 1, 100) >>> y = a*x**(a-1.) >>> normed_y = samples*np.diff(bins)[0]*y >>> plt.plot(x, normed_y) >>> plt.show()
比较功率函数分布与帕累托的倒数。
>>> from scipy import stats >>> rvs = np.random.power(5, 1000000) >>> rvsp = np.random.pareto(5, 1000000) >>> xx = np.linspace(0,1,100) >>> powpdf = stats.powerlaw.pdf(xx,5)
>>> plt.figure() >>> plt.hist(rvs, bins=50, density=True) >>> plt.plot(xx,powpdf,'r-') >>> plt.title('np.random.power(5)')
>>> plt.figure() >>> plt.hist(1./(1.+rvsp), bins=50, density=True) >>> plt.plot(xx,powpdf,'r-') >>> plt.title('inverse of 1 + np.random.pareto(5)')
>>> plt.figure() >>> plt.hist(1./(1.+rvsp), bins=50, density=True) >>> plt.plot(xx,powpdf,'r-') >>> plt.title('inverse of stats.pareto(5)')