Questions tagged [pymc3]

PyMC (formerly PyMC3) is a Python module that implements Bayesian statistical models and fitting algorithms, including Markov chain Monte Carlo. Its flexibility and extensibility make it applicable to a large suite of problems. Along with core sampling functionality, PyMC includes methods for summarizing output, plotting, goodness-of-fit and convergence diagnostics.

PyMC is a Python module that implements Bayesian statistical models and fitting algorithms, including Markov chain Monte Carlo.

Its flexibility and extensibility make it applicable to a large suite of problems. Along with core sampling functionality, PyMC includes methods for summarizing output, plotting, goodness-of-fit and convergence diagnostics.

706 questions
3
votes
1 answer

PyMC3 passing stochastic covariance matrix to pm.MvNormal()

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 …
Fabio
  • 211
  • 1
  • 8
3
votes
1 answer

How to specify size for bernoulli distribution with pymc3?

In trying to make my way through Bayesian Methods for Hackers, which is in pymc, I came across this code: first_coin_flips = pm.Bernoulli("first_flips", 0.5, size=N) I've tried to translate this to pymc3 with the following, but it just returns a…
Marcus Buffett
  • 1,289
  • 1
  • 14
  • 32
3
votes
0 answers

Defining a numeric (custom) likelihood function in PyMC3

After looking at several questions/answers (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) and PyMC3's documentation, I've managed to create a MCVE of my MCMC setup (see below). My fitted parameters are continuous and discrete, so the priors are defined using…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
3
votes
0 answers

pymc3 with custom likelihood function from kernel density estimation

I'm trying to use pymc3 with a likelihood function derived from some observed data. This observed data doesn't fit any nice, standard distribution, so I want to define my own, based on these observations. One approach is to use kernel density…
tomwoodruff
  • 383
  • 1
  • 3
  • 4
3
votes
1 answer

Bad initial energy: inf. The model might be misspecified with basic linear regression model in pymc3

I'm trying to build a bayesian inference model in pymc3 and I'm getting the following error: data = [[24, 38.7], [25, 38.6], [26, 38.9], [27, 41.4], [28, 39.7], [29, 41.1], [30, 38.7], [31, 37.6], [32, 36.3], [33, 36.9], [34, 35.7], [35,…
I. A
  • 2,252
  • 26
  • 65
3
votes
1 answer

Why is linear regression so poor in training using PYMC3

I am new to PYMC3. Maybe this is a naive question, but I searched a lot and didn't find any explanation on this issue. Basically, I want to do a linear regression in PYMC3, however the training is very slow and the model performance on training set…
3
votes
1 answer

Pymc3 python function to deterministic

In this notebook from Bayesian Methods for Hackers, they create a Deterministic variable from a python function as such: # from code line 9 in the notebook @pm.deterministic def lambda_(tau=tau, lambda_1=lambda_1, lambda_2=lambda_2): out =…
RSHAP
  • 2,337
  • 3
  • 28
  • 39
3
votes
1 answer

Creating a shifted & scaled Beta in pymc3

I'm trying to create a beta RV that behaves like the one in scipy. Namely, it takes an alpha, beta, loc, and scale. I followed the discussion on creating a shifted gamma, and came up with something that looks like this: import pymc3 as pm class…
Mike
  • 251
  • 1
  • 12
3
votes
1 answer

Coin tosses, arithmetic of random variables, and PyMC3

I find myself wanting to perform arithmetic of random variables in Python; for the sake of example, let us consider the experiment of repeatedly tossing two independent fair coins and counting the number of heads. Sampling from each random variable…
fuglede
  • 17,388
  • 2
  • 54
  • 99
3
votes
1 answer

Getting posterior distribution of difference between two variables using PYMC3

Now assume we are looking at daily prices of two stocks, A and B. The prior is simple: the prices are all normal distributed, with mu_A and mu_B both uniformly distributed on [10,100] and sigma_A and sigma_B also uniformly distributed on [1,10]. (I…
Cong Ba
  • 31
  • 3
3
votes
1 answer

userWarning pymc3 : What does reparameterize mean?

I built a pymc3 model using the DensityDist distribution. I have four parameters out of which 3 use Metropolis and one uses NUTS (this is automatically chosen by the pymc3). However, I get two different UserWarnings 1.Chain 0 contains number of…
manjula
  • 35
  • 7
3
votes
1 answer

The shape variable in pymc3.DensityDist does not work properly

I am trying to define a multivariate custom distribution through pymc3.DensityDist(); however, I keep getting the following error that dimensions do not match: "LinAlgError: 0-dimensional array given. Array must be two-dimensional" I have already…
KiaSh
  • 147
  • 1
  • 6
3
votes
1 answer

How do I add a constraint to a PyMC3 model?

If we consider the following linear regression example for PyMC3: http://docs.pymc.io/notebooks/getting_started.html#A-Motivating-Example:-Linear-Regression How would we include a constraint such as a + b1 + b2 = 1 or a^2 + b1^2 = 25? I understand…
3
votes
1 answer

Declaring theano variables for pymc3

I am having issues replicating a pymc2 code using pymc3. I believe it is due to the fact pymc3 is using the theano type variables which are not compatible with the numpy operations I am using. So I am using the @theano.decorator: I have this…
Delosari
  • 677
  • 2
  • 17
  • 29
3
votes
1 answer

How to Simulate a Biased 6-sided Dice using Pymc3?

How do I simulate a 6-side Dice roll using Pymc3? Also, what is I know that different sides of the dice have different distributions?
ashish trehan
  • 413
  • 1
  • 5
  • 9