def intensity_function(t, failure_model, T=list(), ϵ=1e-8): """ t : time of interest. gamma: shape parameter of the Weibull distribution with expectation 1. alpha: shape parameter of the power law trend function. beta : scale parameter of the power law trend function. T : time-to-failure data. """ model = failure_model[0] gamma, alpha, beta = failure_model[1] if T[0] != 0: T = [0] + T else: pass if model == "WPLP": if t == 0: if beta < 1 or gamma < 1: return float("inf") else: 0 else: return (alpha * gammafunction(1 + 1 / gamma) )**gamma * gamma * beta * t**(beta - 1) * ( t**beta - T[N(t - ϵ, T)]**beta)**(gamma - 1) elif model == "NHPP": return alpha * beta * t**(beta - 1) elif model == "HPP": return alpha elif model == "WRP": return (alpha * gammafunction(1 + 1 / gamma))**gamma * gamma * t * ( t - T[N(t - ϵ, T)])**(gamma - 1)
def interval_predictor(last_failure, failure_model, ε_1=.025, ε_2=.025): gamma, alpha, beta = failure_model[1] phi = (alpha * gammafunction(1 + 1 / gamma))**gamma T_L = (last_failure**beta + (1 / phi * log(1 / (1 - ε_1)))**(1 / gamma))**(1 / beta) T_U = (last_failure**beta + (1 / phi * log(1 / (ε_2)))**(1 / gamma))**(1 / beta) return [T_L, T_U]
def next_ttf(previous_ttf, final_failure_model, CRN=None): gamma, alpha, beta = final_failure_model[1] U = uniform.rvs(random_state=CRN) tmpA = previous_ttf**beta tmpB = 1 / (alpha * gammafunction(1 + 1 / gamma)) tmpC = log(1 / (1 - U))**(1 / gamma) tmpD = (tmpA + tmpB * tmpC)**(1 / beta) return tmpD
def weibull_dist_func(x, failure_model): gamma, alpha, beta = failure_model[1] return 1 - exp(-(x * gammafunction(1 + 1 / gamma))**gamma)
def alpha_value(gamma, phi): return phi ** (1/gamma) / (gammafunction(1+1/gamma))