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
8
votes
1 answer

Plotting a Model created with PyMC3 as a graph

I am using the following code to create a simple Model with PyMC3: import pymc3 as pm import theano.tensor as tt with pm.Model() as model: p = pm.Uniform("freq_cheating", 0, 1) p_skewed = pm.Deterministic("p_skewed", 0.5*p + 0.25) …
user8270077
  • 4,621
  • 17
  • 75
  • 140
8
votes
3 answers

how to fit a method belonging to an instance with pymc3?

I failed to fit a method belonging to an instance of a class, as a Deterministic function, with PyMc3. Can you show me how to do that ? For simplicity, my case is summarised below with a simple example. In reality, my constraint is that everything…
Stéphane
  • 1,389
  • 3
  • 13
  • 34
8
votes
0 answers

Problems with a hidden Markov model in PyMC3

To learn PyMC, I'm trying to do a simple Hidden Markov Model as shown below: with pymc3.Model() as hmm: # Transition "matrix" a_t = np.ones(num_states) T = [pymc3.Dirichlet('T{0}'.format(i), a = a_t, shape = num_states) for i in…
Javier C.
  • 137
  • 7
8
votes
1 answer

Custom likelihood in pymc3

How can I define a custom likelihood in PyMC3? In PyMC2, I could use @pymc.potential. I tried to use pymc.Potential in PyMC3, however, it seems that boolean operations cannot be applied to the parameters (I get an error like this when I do that).…
Amir Dezfouli
  • 199
  • 3
  • 10
7
votes
1 answer

PYMC3 Bayesian Prediction Cones

I'm still learning PYMC3, but I cannot find anything on the following problem in the docs. Consider the Bayesian Structure Time Series (BSTS) model from this question with no seasonality. This can be modeled in PYMC3 as follows: import pymc3, numpy,…
Paul
  • 503
  • 4
  • 15
7
votes
2 answers

pymc3 multivariate traceplot color coding

I am new to working with pymc3 and I am having trouble generating an easy-to-read traceplot. I'm fitting a mixture of 4 multivariate gaussians to some (x, y) points in a dataset. The model runs fine. My question is with regard to manipulating the…
R. Barrett
  • 244
  • 2
  • 13
7
votes
1 answer

pymc3: hierarchical model with multiple obsesrved variables

I have a simple hierarchical model with lots of individuals for which I have small samples from a normal distribution. The means of these distributions also follow a normal distribution. import numpy as np n_individuals = 200 points_per_individual…
DanT
  • 3,960
  • 5
  • 28
  • 33
7
votes
1 answer

How to set Bernoulli distribution parameters in pymc3

I have a model described in pymc3 using the following: from pymc3 import * basic_model = Model() with basic_model: # Priors for unknown model parameters alpha = Normal('alpha', mu=0, sd=10) beta = Normal('beta', mu=0, sd=10,…
recluze
  • 1,920
  • 4
  • 21
  • 34
6
votes
1 answer

Theano Lock Issue for pymc3 with Python 3.8 and macOS15 (Catalina)

Recently, I upgraded macOS to macOS15 (Catalina) with the latest Anaconda Navigator (with Python 3.8). When I run pymc3, I encountered: INFO (theano.gof.compilelock): Waiting for existing lock by process '38830' (I am process '40110') INFO…
STsutsui
  • 61
  • 1
6
votes
2 answers

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

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…
merv
  • 67,214
  • 13
  • 180
  • 245
6
votes
3 answers

Custom Theano Op to do numerical integration

I'm attempting to write a custom Theano Op which numerically integrates a function between two values. The Op is a custom likelihood for PyMC3 which involves the numerical evaluation of some integrals. I can't simply use the @as_op decorator as I…
tmm13
  • 108
  • 4
6
votes
1 answer

what does the 'find_MAP' output mean in pymc3?

What are the returned values of find_MAP in pymc3 ? It seems that pymc3.Normal and pymc3.Uniform variables are not considered the same: for pymc3.Normal variables, find_MAP returns a value that looks like the maximum a posteriori probability. But…
Stéphane
  • 1,389
  • 3
  • 13
  • 34
6
votes
0 answers

How to use pymc to parameterize a probabilistic graphical model?

How can one use pymc to parameterize a probabilistic graphical model? Suppose I have a PGM with two nodes X and Y. Lets say X->Y is the graph. And X takes two values {0,1}, and Y also takes two values {0,1}. I want to use pymc to learn the…
6
votes
1 answer

Modified BPMF in PyMC3 using `LKJCorr` priors: PositiveDefiniteError using `NUTS`

I previously implemented the original Bayesian Probabilistic Matrix Factorization (BPMF) model in pymc3. See my previous question for reference, data source, and problem setup. Per the answer to that question from @twiecki, I've implemented a…
Mack
  • 2,614
  • 2
  • 21
  • 33
6
votes
2 answers

how to sample multiple chains in PyMC3

I'm trying to sample multiple chains in PyMC3. In PyMC2 I would do something like this: for i in range(N): model.sample(iter=iter, burn=burn, thin = thin) How should I do the same thing in PyMC3? I saw there is a 'njobs' argument in the…
Amir Dezfouli
  • 199
  • 3
  • 10
1
2
3
47 48