pymc3

How to get scipy.special functions to take pymc3 RV's as input

狂风中的少年 提交于 2020-05-17 07:01:27
问题 I'm trying to use pymc3 to fit a model involving the voigt function (coming from scipy.special). The inputs to the voigt function are supposed to be arrays, whereas a,b are pymc3 classes. How do I get scipy.special functions to take pymc3 RV's as input? Running the code attached below produces an error: import pymc3 as pm from scipy.special import voigt_profile import numpy as np with pm.Model() as linear_model: a = pm.Lognormal('a',mu=0, sigma=2.) b = pm.Lognormal('b',mu=0, sigma=2.) x = np

colaboratory will not acknowledge arviz after installation and import

馋奶兔 提交于 2020-05-15 02:05:34
问题 In Google's colaboratory, installed arviz then did import arviz without error, but in a code cell, pm.plot_posterior(samples) gets error: arviz not installed. Trying to plot Bayesian code pm.plot_posterior(samples) I expect a plot 回答1: Install Arviz prior to importing PyMC3 , otherwise it apparently cannot find it. In your case, simply restarting the runtime ( Runtime > Restart runtime... ) should get it working. 回答2: Hi did you try adding the cell magic %matplotlib inline ? This may be an

colaboratory will not acknowledge arviz after installation and import

故事扮演 提交于 2020-05-15 02:04:44
问题 In Google's colaboratory, installed arviz then did import arviz without error, but in a code cell, pm.plot_posterior(samples) gets error: arviz not installed. Trying to plot Bayesian code pm.plot_posterior(samples) I expect a plot 回答1: Install Arviz prior to importing PyMC3 , otherwise it apparently cannot find it. In your case, simply restarting the runtime ( Runtime > Restart runtime... ) should get it working. 回答2: Hi did you try adding the cell magic %matplotlib inline ? This may be an

Error: non-constant-expression cannot be narrowed from type 'npy_intp' to 'int'

浪子不回头ぞ 提交于 2020-05-10 21:14:13
问题 I am trying to run the following model, but it fails during compilation: import numpy as np import pymc3 as pm def sample_data(G=1, K=2): # mean proportion ([0,1]) for each g p_g = np.random.beta(2, 2, size=G) # concentration around each p_g c_g = np.random.lognormal(mean=0.5, sigma=1, size=G) # reparameterization for standard Beta(a,b) a_g = c_g * p_g / np.sqrt(p_g**2 + (1.-p_g)**2) b_g = c_g*(1.-p_g) / np.sqrt(p_g**2 + (1.-p_g)**2) # for each p_g, sample K proportions p_gk = np.random.beta

Error: non-constant-expression cannot be narrowed from type 'npy_intp' to 'int'

﹥>﹥吖頭↗ 提交于 2020-05-10 21:13:17
问题 I am trying to run the following model, but it fails during compilation: import numpy as np import pymc3 as pm def sample_data(G=1, K=2): # mean proportion ([0,1]) for each g p_g = np.random.beta(2, 2, size=G) # concentration around each p_g c_g = np.random.lognormal(mean=0.5, sigma=1, size=G) # reparameterization for standard Beta(a,b) a_g = c_g * p_g / np.sqrt(p_g**2 + (1.-p_g)**2) b_g = c_g*(1.-p_g) / np.sqrt(p_g**2 + (1.-p_g)**2) # for each p_g, sample K proportions p_gk = np.random.beta

Error: non-constant-expression cannot be narrowed from type 'npy_intp' to 'int'

三世轮回 提交于 2020-05-10 21:12:07
问题 I am trying to run the following model, but it fails during compilation: import numpy as np import pymc3 as pm def sample_data(G=1, K=2): # mean proportion ([0,1]) for each g p_g = np.random.beta(2, 2, size=G) # concentration around each p_g c_g = np.random.lognormal(mean=0.5, sigma=1, size=G) # reparameterization for standard Beta(a,b) a_g = c_g * p_g / np.sqrt(p_g**2 + (1.-p_g)**2) b_g = c_g*(1.-p_g) / np.sqrt(p_g**2 + (1.-p_g)**2) # for each p_g, sample K proportions p_gk = np.random.beta

Summing RVs using PYMC3

我的梦境 提交于 2020-03-23 08:00:38
问题 I am attempting to implement the model from the image. I am new to PyMC3 and I am not sure how to structure the model correctly. My attempt is below: # sample data logprem = np.array([8.66768002, 8.49862181, 8.60410456, 8.54966038, 8.55910259, 8.56216656, 8.51559191, 8.60630237, 8.56140145, 8.50956416]) with Model() as model: logelr = Normal('logelr', -0.4, np.sqrt(10), shape=10) α0 = 0 β9 = 0 α = Normal('α', 0, sigma=np.sqrt(10), shape=9) β = Normal('β', 0, sigma=np.sqrt(10), shape=9) a =