コード例 #1
0
    parameters = zeros((2, size))
    parameters[0, :] = sigma_w
    parameters[1, :] = sigma_v
    return parameters

## Prior hyperparameters
hyperparameters = { \
        "sigma_w_shape": 1, \
        "sigma_w_scale": 1, \
        "sigma_v_shape": 1, \
        "sigma_v_scale": 1}

modeltheta = ParameterModel(name = "Periodic Gaussian model theta", dimension = 2)
modeltheta.setHyperparameters(hyperparameters)
modeltheta.setPriorlogdensity(logdprior)
modeltheta.setPriorgenerator(rprior)
modeltheta.setParameterNames(["expression(sigma[w]^2)", "expression(sigma[v]^2)"])
modeltheta.setTransformation(["log", "log"])
modeltheta.setRtruevalues([10, 1])
InverseGammaTemplate = """
priorfunction <- function(x){
    shape <- %.5f 
    scale <- %.5f
    return(scale**shape / gamma(shape) * x**(- shape - 1) * exp(-scale / x))
}
"""
modeltheta.setRprior([InverseGammaTemplate %
    (hyperparameters["sigma_w_shape"], hyperparameters["sigma_w_scale"]), \
InverseGammaTemplate % (hyperparameters["sigma_v_shape"],
    hyperparameters["sigma_v_scale"])])