반응형

/*******************************************************************************************************************
-- Title : [Py.35] Probability Plot w/ Scipy and Matplotlib
-- Reference : docs.scipy.org/doc
-- Key word : matplotlib pyplot probplot scipy plot chart 차트 그래프 graph 
*******************************************************************************************************************/

■ Figures


 
■ Scripts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
 
# REf : https://docs.scipy.org/doc/scipy-0.19.0/reference/generated/scipy.stats.probplot.html
 
nsample = 100
np.random.seed(7654321)
 
# ------------------------------
# A t distribution with small degrees of freedom:
# ------------------------------
ax1 = plt.subplot(221)
x1 = stats.t.rvs(3, size=nsample)
res = stats.probplot(x1, plot=plt)
 
 
# ------------------------------
# A t distribution with larger degrees of freedom:
# ------------------------------
ax2 = plt.subplot(222)
x2 = stats.t.rvs(25, size=nsample)
res = stats.probplot(x2, plot=plt)
 
 
# ------------------------------
# A mixture of two normal distributions with broadcasting:
# ------------------------------
ax3 = plt.subplot(223)
x3 = stats.norm.rvs(loc=[0,5], scale=[1,1.5], size=(nsample//2,2)).ravel()
res = stats.probplot(x3, plot=plt)
 
 
# ------------------------------
# A standard normal distribution:
# ------------------------------
ax4 = plt.subplot(224)
x4 = stats.norm.rvs(loc=0, scale=1, size=nsample)
res = stats.probplot(x4, plot=plt)
 
# Produce a new figure with a loggamma distribution, using the ``dist`` and
# ``sparams`` keywords:
 
plt.show()
 
 
# ------------------------------
# -- Show the result
# ------------------------------
fig = plt.figure()
ax = fig.add_subplot(111)
x5 = stats.loggamma.rvs(c=2.5, size=500)
res = stats.probplot(x5, dist=stats.loggamma, sparams=(2.5,), plot=ax)
ax.set_title("Probplot for loggamma dist with shape parameter 2.5")
 
plt.show()
 
 



반응형

+ Recent posts