我正在使用以下设置处理EVT模型:
以pm.Model()作为模型:
File "D:/projects/side_master/src/documentation/src/2.txt" not found.
它基于广义帕累托分布,用于超过给定阈值的样本(已在data_ex_neg_tail_inv中选择)
我真正想做的是使用这些reference priors。
但是我目前不知道如何在pymc3中完成此操作,因为它们是根据pymc3建模似乎不允许的随机变量本身制定的(?)。
我要使用的公式是(用于scale参数):
# Generalized Pareto.
def gpd_logp(x, sigma, xi):
if eta == 0:
return pm.math.log(1/sigma) - x
else:
return pm.math.log(1/sigma) - (xi+1)/xi * pm.math.log(xi*x + 1)
# Draw random samples.
def gpd_random(point=None, size=None, **kwargs):
sigma = point['sigma']
eta = point['xi']
# Uniforms for use in inverse CDF
u = np.random.uniform(size=size)
if eta == 0:
return -sigma * np.log(u)
else:
return sigma*((u**-xi) - 1)/xi
# Pymc3 combines random variable and distribution into one.
# That's incorrect modeling. I can't use the
# least informative reference prior for scale and shape parameters.
sigma = pm.InverseGamma('sigma', alpha=2, beta=1)
xi = pm.Uniform('xi', lower=0, upper=0.5)
pt = pm.DensityDist('gpd', gpd_logp, random=gpd_random, observed={'x':data_ex_neg_tail_inv, 'sigma':sigma, 'xi':xi})
trace = pm.sample(1000, tune=500, cores=6)
post_pred = pm.sample_posterior_predictive(trace)
有什么办法可以实现?