根据数据确定威布尔参数

根据数据确定威布尔参数

本文介绍了根据数据确定威布尔参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想识别 Weibull参数(我的数据的形状和比例).

I would like to identify the Weibull parameters (i.e. the shape and scale) of my data.

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

我已经尝试了此答案提出的建议,我m使用Python 3.4.

I've already tried what this answer proposed, and I'm using 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中添加第二列(或行)时,出现错误,无法将字符串值转换为浮点数.

I assume that the data in my csv file was read as x-input values, instead of the y-values of the Weibull function. When I add a second column (or row) with bin, it gives an error that string values can not be converted into floats.

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

How do I need to modify my csv file in order to use the data within as the y-values of the Weibull function?

我认为我的问题可能是我不明白这一行:

I think my problem might be that I don't understand this line:

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

1, 1在这里代表什么?然后,这些参数不应为负.

What does 1, 1 represent here? The parameters should then not be negative.

推荐答案

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

It looks like you want to use the fit method of scipy.stats.weibull_min (which is an alias for scipy.stats.frechet_r). Use the argument floc=0 to constrain the location to be 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

这篇关于根据数据确定威布尔参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:02