使数据适合不同的分布并通过ks检验选择最佳分布

时间:2019-07-04 10:24:46

标签: python

我有一个数据,我想将其拟合到不同的分布中,即正态分布,伽马,对数三,β,维布尔,广义极值,一般pareto。并通过执行ks test来选择最佳分布

import pandas as pd
import numpy as np
import matplotlib
import scipy.stats as sp
import matplotlib.pyplot as plt
import statistics as st
from decimal import Decimal, ROUND_HALF_UP

rld=pd.read_excel(r"C:\Users\DELL\nagrajun sagar reservoir data - Copy.xlsx")
rld.head()
output:

October 2  October  3  October  4  October  5  October  6  October  7  October  8  October  9  October  10  October ... 22  October 23  October 24  October 25  October 26  October 27  October 28  October 29  October 30  October 31  October
0   2.070   2.070   2.014   2.272   2.464   2.619   2.632   2.638   2.638   2.788   ... 4.442   4.551   4.645   4.753   4.784   4.776   4.776   4.761   4.745   4.730
1   1.520   1.579   1.596   1.620   1.639   1.642   1.654   1.648   1.744   1.897   ... 5.520   5.562   5.595   5.644   5.644   5.611   5.570   5.520   5.495   5.470
2   0.856   0.823   0.779   0.724   0.663   0.619   0.592   0.559   0.534   0.508   ... 0.614   0.646   0.658   0.652   0.647   0.647   0.659   0.686   0.712   0.680
3   0.370   0.370   0.370   0.370   0.370   0.385   0.385   0.390   0.378   0.378   ... 0.355   0.344   0.344   0.344   0.344   0.344   0.344   0.344   0.344   0.344
4   2.713   2.728   2.701   2.692   2.755   2.802   2.948   3.189   3.360   3.456   ... 3.685   3.678   3.649   3.649   3.640   3.670   3.644   3.619   3.592   3.55

rl = rld.iloc[:,1].sort_values().reset_index(drop=True)
0     0.043
1     0.370
2     0.391
3     0.823
4     1.105
5     1.579
6     2.070
7     2.235
8     2.728
9     4.490
10    4.905
11    5.036
12    5.074
13    6.481
14    6.613
15    6.806
16    6.807
17    6.824
18    6.841
Name:  2  October, dtype: float64

我想将不同分布拟合到此数据,并通过执行ks测试找出最佳分布

0 个答案:

没有答案