根据数据确定 Weibull 参数

Determine Weibull parameters from data

我想确定我的数据的 Weibull parameters(即形状和比例)。

0.022988506
0.114942529
0.218390805
0.114942529
0.149425287
0.114942529
0.068965517
0.068965517
0.034482759
0.022988506
0.022988506
0.022988506
0.022988506

我已经尝试了 this answer 建议的方法,我正在使用 Python 3.4.

import scipy.stats as s
import numpy as np
from scipy import stats


def weib(x,n,a):
    return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a)


data = np.loadtxt("data1.csv")
print(data)
(loc, scale) = s.exponweib.fit_loc_scale(data, 1, 1)
print('loc is: ',loc, '\n scale is: ', scale)

这给了我以下输出:

[0.02298851  0.11494253  0.2183908   0.11494253  0.14942529  0.11494253   0.06896552  0.06896552  0.03448276  0.02298851  0.02298851  0.02298851 0.02298851]
loc is:  0.0574417296258 
scale is:  0.0179259738449

我假设我的 csv 文件中的数据被读取为 x 输入值,而不是 Weibull 函数的 y 值。当我用 bin 添加第二列(或行)时,它给出了一个错误,即字符串值无法转换为浮点数。

我需要如何修改我的 csv 文件才能将其中的数据用作 Weibull 函数的 y 值?

我想我的问题可能是我不理解这一行:

(loc, scale) = s.exponweib.fit_loc_scale(data, 1, 1)

这里的1, 1代表什么?参数不应为负。

您似乎想使用 scipy.stats.weibull_minfit 方法(这是 scipy.stats.frechet_r 的别名)。使用参数 floc=0 将位置限制为 0.

In [9]: data
Out[9]: 
array([ 0.02298851,  0.11494253,  0.2183908 ,  0.11494253,  0.14942529,
        0.11494253,  0.06896552,  0.06896552,  0.03448276,  0.02298851,
        0.02298851,  0.02298851,  0.02298851])

In [10]: from scipy.stats import weibull_min

In [11]: shape, loc, scale = weibull_min.fit(data, floc=0)

In [12]: shape
Out[12]: 1.3419930069121602

In [13]: scale
Out[13]: 0.084273047253525968