如何求Weibull分布对应63.2%概率的x截距?斜率过高排查
Weibull概率绘图:尺度参数计算与斜率问题解析
一、计算尺度参数(63.2%概率对应的x截距)
当累积失效概率p=63.2%时,代入Weibull概率变换公式:y = ln(-ln(1-p))
计算得:1-p = 1 - 0.632 = 0.368ln(0.368) ≈ -1-ln(0.368) ≈ 1ln(1) = 0
此时y值为0,结合拟合直线方程 y = slope * x + intercept,令y=0解x:x = -intercept / slope
由于x是ln(E),因此尺度参数η = exp(x)。
在代码中添加以下计算逻辑:
# 计算尺度参数 y_632 = np.log(-np.log(1 - 0.632)) # 保留计算过程保证严谨性,理论值为0 x_intercept = (y_632 - intercept) / slope scale = np.exp(x_intercept) print("Scale parameter:", scale)
二、斜率过高的原因分析
从你的数据集来看,电击穿强度E的取值范围极小(仅从208.9到210,跨度约1.1),而对应的概率变换后y值的跨度却很大(从≈-2.77到≈0.88)。线性拟合的斜率是y的变化量除以x的变化量,x(即ln(E))的跨度仅约0.004,y的跨度约3.65,因此斜率自然会非常大(≈910)。
另外你的绘图代码存在一处错误:生成拟合线的x范围误用了y轴的最大值,导致拟合线超出实际数据的x范围。修正如下:
原错误代码:
x = np.linspace(min(x_data), max(y_data), 100)
修正后:
x = np.linspace(min(x_data), max(x_data), 100)
三、修正后的完整代码
import numpy as np import matplotlib.pyplot as plt # Define the parameters n = 8 # Sample size i = np.arange(1, n + 1) # Rank of observations E = np.array([208.9, 209.0, 209.2, 209.3, 209.6, 209.8, 209.9, 210]) # Electric breakdown strength # Calculate the cumulative breakdown efficiency by the given formula p = (i - 0.5) / (n + 0.25) # variables x_data = np.log(E) y_data = np.log(-np.log(1 - p)) # Fit a linear regression to estimate the parameters of the Weibull distribution slope, intercept = np.polyfit(x_data, y_data, 1) # Calculate the shape parameter shape = slope # 计算尺度参数(对应p=63.2%的x截距) y_632 = np.log(-np.log(1 - 0.632)) x_intercept = (y_632 - intercept) / slope scale = np.exp(x_intercept) # Generate points for the Weibull distribution(修正x范围) x = np.linspace(min(x_data), max(x_data), 100) y = slope * x + intercept # Plot the Weibull distribution plt.plot(x_data, y_data, 'o') plt.plot(x, y, label='Linear fit') plt.xlabel('ln (E)') plt.ylabel('ln(-ln(1 - p))') plt.title('Weibull Plot') plt.legend() plt.show() print("Shape parameter:", slope) print("Scale parameter:", scale)
补充说明
- 你使用的
p=(i-0.5)/(n+0.25)是常用的中位秩估计方法,公式本身无问题; - 若E的取值确实如此集中,斜率高是正常现象,说明数据在对数尺度下离散程度极小,但失效概率变化快;
- 若怀疑数据异常,可检查测试过程是否存在偏差,或增加样本量获取更分散的数据。
内容的提问来源于stack exchange,提问作者Arindam Das
相关产品推荐
相关产品推荐

