pymc3

PyMC3 passing stochastic covariance matrix to pm.MvNormal()

落爺英雄遲暮 提交于 2021-02-10 16:47:45
问题 I've tried to fit a simple 2D gaussian model to observed data by using PyMC3. import numpy as np import pymc3 as pm n = 10000; np.random.seed(0) X = np.random.multivariate_normal([0,0], [[1,0],[0,1]], n); with pm.Model() as model: # PRIORS mu = [pm.Uniform('mux', lower=-1, upper=1), pm.Uniform('muy', lower=-1, upper=1)] cov = np.array([[pm.Uniform('a11', lower=0.1, upper=2), 0], [0, pm.Uniform('a22', lower=0.1, upper=2)]]) # LIKELIHOOD likelihood = pm.MvNormal('likelihood', mu=mu, cov=cov,

Calculating WAIC for models with multiple likelihood functions with pymc3

对着背影说爱祢 提交于 2021-01-29 11:45:01
问题 I try to predict the outcome of soccer games based on the number of goals scored and I use the following model: with pm.Model() as model: # global model parameters h = pm.Normal('h', mu = mu, tau = tau) sd_a = pm.Gamma('sd_a', .1, .1) sd_d = pm.Gamma('sd_d', .1, .1) alpha = pm.Normal('alpha', mu=mu, tau = tau) # team-specific model parameters a_s = pm.Normal("a_s", mu=0, sd=sd_a, shape=n) d_s = pm.Normal("d_s", mu=0, sd=sd_d, shape=n) atts = pm.Deterministic('atts', a_s - tt.mean(a_s)) defs =

arviz.plot_ppc: “posterior predictive mean”

两盒软妹~` 提交于 2021-01-28 19:13:27
问题 Hello! After running a model for a simple linear regression model in pymc3, I'm trying to do a plot. As you can see both plots show the "posterior predictive mean score", but I was wondering whether can I plot this distribution around the "posterior predictive mean score" (not around "observed score"), in arviz, similar to what is shown in the first figure? Both figures were made using the same data: Score <- c(78.93,58.2,67.47,37.47,45.65,32.92,29.97) Drugs <- c(1.17,2.97,3.26,4.69,5.83,6,6

pymc with observations on multiple variables

左心房为你撑大大i 提交于 2021-01-28 08:25:50
问题 I'm using an example of linear regression from bayesian methods for hackers but having trouble expanding it to my usage. I have observations on a random variable, an assumed distribution on that random variable, and finally another assumed distribution on that random variable for which I have observations. How I have tried to model it is with intermediate distributions on a and b , but it complains Wrong number of dimensions: expected 0, got 1 with shape (788,). To describe the actual model,

Updating model on PyMC3 with new observed data

浪子不回头ぞ 提交于 2020-12-04 09:01:59
问题 I have measured the diameter of 80 fruits last year, and after checking what is the best distribution of the values, I've created a PyMC3 model with Model() as diam_model: mu = Normal('mu',mu=57,sd=5.42) sigma = Uniform('sigma',0,10) after, as far as I understand, I've "trained" the model with my prior data (the 80 values) with diam_model: dist = Normal('dist',mu=mu,sd=sigma, observed=prior_data.values) with diam_model: samples=fit().sample(1000) then I used the plot_posterior of the samples

Updating model on PyMC3 with new observed data

末鹿安然 提交于 2020-12-04 09:00:34
问题 I have measured the diameter of 80 fruits last year, and after checking what is the best distribution of the values, I've created a PyMC3 model with Model() as diam_model: mu = Normal('mu',mu=57,sd=5.42) sigma = Uniform('sigma',0,10) after, as far as I understand, I've "trained" the model with my prior data (the 80 values) with diam_model: dist = Normal('dist',mu=mu,sd=sigma, observed=prior_data.values) with diam_model: samples=fit().sample(1000) then I used the plot_posterior of the samples

Updating model on PyMC3 with new observed data

依然范特西╮ 提交于 2020-12-04 08:59:51
问题 I have measured the diameter of 80 fruits last year, and after checking what is the best distribution of the values, I've created a PyMC3 model with Model() as diam_model: mu = Normal('mu',mu=57,sd=5.42) sigma = Uniform('sigma',0,10) after, as far as I understand, I've "trained" the model with my prior data (the 80 values) with diam_model: dist = Normal('dist',mu=mu,sd=sigma, observed=prior_data.values) with diam_model: samples=fit().sample(1000) then I used the plot_posterior of the samples