python創建類統計屬性
介紹 (Introduction)
Sometimes you may need a distribution figure for your slide or class. Since you are not using data, you want a quick solution.
有時,您的幻燈片或課程可能需要一個分配圖。 由于您不使用數據,因此需要快速解決方案。
A Python package, Statsfig, can create different distribution figures with one line of code.
Python套件Statsfig可以用一行代碼創建不同的分布圖。
I’d like to show you how easy it is to create each figure.
我想向您展示創建每個圖形有多么容易。
安裝 (Installation)
Using pip
:
使用pip
:
pip install statsfig
Then import it.
然后導入。
import statsfig as sf
功能清單 (List of Functions)
There are eleven functions you can use. Ten distribution functions and one plot.
您可以使用十一個功能。 十個分布函數和一個圖。
演示地址
伯努利分布 (Bernoulli distribution)
bernofig() (bernofig())
The bernofig()
function creates a Bernoulli distribution and the following table shows all the parameters.
bernofig()
函數創建一個Bernoulli分布,下表顯示了所有參數。
演示地址
The default function has a probability of 0.5 and a size of 1000.
默認函數的概率為0.5,大小為1000。
演示地址
The following example shows a probability of 0.6, a different color, and without the grid.
以下示例顯示了0.6的概率,不同的顏色并且沒有網格。
演示地址
二項分布 (Binomial Distribution)
binofig() (binofig())
The binofig()
function creates a binomial distribution and the following table shows all the parameters.
binofig()
函數創建一個二項式分布,下表顯示了所有參數。
演示地址
The default function has a probability of 0.5 and a size of 1000.
默認函數的概率為0.5,大小為1000。
演示地址
The following example has a probability of 0.7, the number is trials of 30 and shifting 1 to the right.
下面的示例的概率為0.7,次數為30,向右移動1。
演示地址
箱須圖 (Box and Whisker Plot)
This is the only one that is not a distribution figure.
這是唯一一個沒有分配數字的人。
箱形圖() (boxplot())
The boxplot()
function creates a box and whisker plot and the following table shows all the parameters.
boxplot()
函數創建一個箱須圖,下表顯示了所有參數。
演示地址
The default function has the following value for the info
argument.
默認函數的info
參數具有以下值。
{‘bplot 1’:[-9, -4, 2, 4, 9], ‘bplot 2’:[-5, -2, 1, 3, 8], ‘bplot 3’:[1, 4, 6, 8, 10]}
The info
must have a dictionary form with name:[min, lower quartile, median, upper quartile, max]
.
info
必須具有name:[min, lower quartile, median, upper quartile, max]
的字典形式。
演示地址
If you want to show only one box and whisker plot, you can do this:
如果您只想顯示一個方框圖和晶須圖,則可以執行以下操作:
演示地址
Changing vert=False
displays the plot horizontally.
更改vert=False
會水平顯示繪圖。
演示地址
卡方分布 (Chi-square Distribution)
chifig() (chifig())
The chifig()
function creates a Chi-square distribution and the following table shows all the parameters.
chifig()
函數創建一個卡方分布,下表顯示了所有參數。
演示地址
The default function has [1,4,6,7] for the degree of freedom.
默認功能的自由度為[1,4,6,7]。
演示地址
You can change the degrees of freedom by changing the dof
argument using a python list as following.
您可以使用以下python列表通過更改dof
參數來更改dof
。
演示地址
指數分布 (Exponential Distribution)
expofig() (expofig())
The expofig()
function creates an Exponential distribution and the following table shows all the parameters.
expofig()
函數創建指數分布,下表顯示了所有參數。
演示地址
The default function has a standard deviation of 1 and size of 1000.
默認功能的標準偏差為1,大小為1000。
演示地址
You can hide the histogram by changing the hist
argument to False
.
您可以通過將hist
參數更改為False
來隱藏直方圖。
演示地址
伽瑪分布 (Gamma Distribution)
gammafig() (gammafig())
The gammafig()
function creates a Gamma distribution and the following table shows all the parameters.
gammafig()
函數創建一個Gamma分布,下表顯示了所有參數。
演示地址
The default function has a shape parameter of 5 and a size of 1000.
默認函數的shape參數為5,大小為1000。
演示地址
You can change the color by changing the color
argument. You can use one of the characters {'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}
, which are short-hands for blue, green, red, cyan, magenta, yellow, black, and white. You can also use a hex RGB or RGBA string (e.g., '#4287f5'
or '#4287f580'
).
您可以通過更改color
參數來更改color
。 您可以使用以下字符之一: {'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}
,它們是藍色,綠色的簡寫形式,紅色,青色,洋紅色,黃色,黑色和白色。 您也可以使用十六進制RGB或RGBA字符串(例如'#4287f5'
或'#4287f580'
)。
演示地址
正態分布 (Normal Distribution)
規范 (normcdf)
The normcdf()
function creates a Normal distribution and the following table shows all the parameters.
normcdf()
函數創建一個正態分布,下表顯示了所有參數。
演示地址
The default function has a mean of 0 and a standard deviation of 1.
默認函數的平均值為0,標準偏差為1。
演示地址
If you wish, you can change most of the arguments as follows:
如果愿意,可以如下更改大多數參數:
演示地址
Changing the lb
, the lower quartile and the ub
, the upper quartile, you can find the probability of between two values.
更改lb
(下四分位數)和ub
(上四分位數),您可以找到兩個值之間的概率。
演示地址
規范pdf_std (normpdf_std)
The normpdf_std()
function creates a Normal distribution with different standard deviations. The following table shows all the parameters.
normpdf_std()
函數創建具有不同標準偏差的正態分布。 下表顯示了所有參數。
演示地址
The default function has [1,2,3,4] for the degrees of freedom to display.
默認功能的顯示自由度為[1,2,3,4]。
演示地址
You can use a Python list to change the val
argument for different degrees of freedom.
您可以使用Python列表更改不同自由度的val
參數。
演示地址
normpdf_mean (normpdf_mean)
The normpdf_mean()
function creates a Normal distribution with different means. The following table shows all the parameters.
normpdf_mean()
函數使用不同的方式創建正態分布。 下表顯示了所有參數。
演示地址
The default function has [0,1,2,3] for the mean values to display.
默認功能的平均值顯示為[0,1,2,3]。
演示地址
You can change the title, x-axis minimum, and maximum values as follows:
您可以如下更改標題,x軸最小值和最大值:
演示地址
泊松分布 (Poisson Distribution)
poisfig() (poisfig())
The poisfig()
function creates a Poisson distribution and the following table shows all the parameters.
poisfig()
函數創建一個泊松分布,下表顯示了所有參數。
演示地址
The default function has 4 the μ value and a size of 1000.
默認函數的μ值為4,大小為1000。
演示地址
演示地址
均勻分布 (Uniform Distribution)
uniformfig() (uniformfig())
The uniformfig()
function creates a Uniform distribution and the following table shows all the parameters.
uniformfig()
函數創建一個Uniform分布,下表顯示了所有參數。
演示地址
The default function has a size of 1000, start at 10 and a width of 20.
默認功能的大小為1000,從10開始,寬度為20。
演示地址
Here we are changing the color, grid, and figure width and length.
在這里,我們更改顏色,網格以及圖形的寬度和長度。
演示地址
終奌站 (Terminal)
You can create a figure from your terminal as well.
您也可以從終端創建圖形。


結論 (Conclusion)
I hope you found it is much easier to create figures with the Statsfig package. I’d love to hear any comments about the package. Feel free to leave a message below, or reach out to me through Twitter.
我希望您發現使用Statsfig軟件包創建圖形要容易得多 。 我希望聽到有關該包裹的任何評論。 隨時在下面留言,或通過Twitter與我聯系。
Please stay tuned for the next post.
請繼續關注下一篇文章。
翻譯自: https://towardsdatascience.com/a-python-package-to-create-stats-figures-with-ease-503cf6ec0b26
python創建類統計屬性
本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。 如若轉載,請注明出處:http://www.pswp.cn/news/391970.shtml 繁體地址,請注明出處:http://hk.pswp.cn/news/391970.shtml 英文地址,請注明出處:http://en.pswp.cn/news/391970.shtml
如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!