Questions tagged [pymc]

PyMc is a Python module for providing Bayesian statistical models, algorithms and estimations. Two versions are currently widely used: 2 and 3, that are significantly different. Version 2 is not supported anymore, but version 3 is not fully compatible with previous codes and translating a V2-code to V3 is not always straightforward. If you have a PyMc question specific to V3, consider using the [pymc3] tag in addition to the [pymc] tag.

Pymc is a Python module for providing Bayesian statistical models and algorithms. It requires Numpy. PyMC includes methods for summarizing output, plotting, goodness-of-fit and convergence diagnostics.

According to its documentation, Pymc's notable features include:

  • Bayesian statistical models with Markov chain Monte Carlo and other algorithms.
  • A suite of statistical distributions.
  • A module for modeling Gaussian processes.
  • Creates summaries including tables and plots.
  • Extensible

Source: https://github.com/pymc-devs/pymc
Pypi: https://pypi.python.org/pypi/pymc
Docs: http://pymc-devs.github.io/pymc/

511 questions
0
votes
2 answers

Pymc 2d gaussian fitting

I am trying to fit a predefined 2d gaussian function to some observed data with pymc. I keep running into errors and the last one I got was ValueError: setting an array element with a sequence. I understand what the error means, but I am not sure…
0
votes
1 answer

TruncatedNormal bug or my error?

This simple example: import numpy as np import pymc as pm init = 0.5; minv = 0.; maxv = 1. A = pm.Uniform('A', value=init, lower=minv, upper=maxv) B = pm.TruncatedNormal('B', value=init, mu=A, tau=1., a=minv, b=maxv) C = pm.Normal('C',…
daur
  • 3
  • 1
0
votes
3 answers

change point detection with two transitions

this question was asked previously and not answered (5 June) but maybe putting it in context makes more sense. I have done the change point tutorial with the two lambdas and extended with 2 change point so the modelling is now: # the exp parameter…
user2471214
  • 729
  • 9
  • 17
0
votes
1 answer

Defining the exponential prior with jumping order of magnitude in parameter space

I want to define an Exponential prior for a parameter as following Therefore I have defined it in pymc with @pm.stochastic def MASS(value=math.pow(10,15), rate = math.pow(10,15)): """mass is a stochastic parameter with exponential…
Dalek
  • 4,168
  • 11
  • 48
  • 100
0
votes
1 answer

Defining priors and marginalizing over priors in pymc

I am going through the tutorial about Monte Carlo Markov Chain process with pymc library. I am also a newbie using pymc and try to establish my own MCMC process. I have faced couple of question that I couldn't find proper answer in pymc…
Dalek
  • 4,168
  • 11
  • 48
  • 100
0
votes
1 answer

TypeError: hasattr(): attribute name must be string in pymc

I have looked at the following links but none of them provide the solution I am looking for https://github.com/pymc-devs/pymc/issues/125 PyMC error : hasattr(): attribute name must be string I have to write a function which given the priors (and…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

Get parameter list of pymc object

I am trying to write a generic function which accepts a user-defined function, a list of priors(apart from other things) and the does something (irrelevant for this question) for eg ( ... in the following code-snippets refers to irrelevant…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

Normal Approximation versus MAP in pymc

Can anyone explain to me what does Normal Approximation do over and above what is done by MAP in some easy words? I have read enough on http://pymc-devs.github.io/pymc/modelfitting.html#normal-approximations but it is too complicated for me. An…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
0 answers

Gamma Distributions in Pymc - Bayesian Testing

I've closely followed this book (http://nbviewer.ipython.org/github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter2_MorePyMC/MorePyMC.ipynb) but have found myself running into problems when trying to…
Kali_89
  • 617
  • 2
  • 7
  • 21
0
votes
2 answers

PyMC MCMC analysis - .summary() "

I'm new to PyMC and am having a little trouble getting out parameters related to my prior, for example, the mean and standard deviation. I describe my model in a file called 'model.py' like so: import pymc import numpy #constants …
0
votes
1 answer

Two execution of MAP in pymc gives different values

I wanted to learn about MAP optimization im pymc. I got the following posterior distribution of lambda after sampling using mcmc Clearly, the posterior is maximum at lambda = 0.20 and the 95% intervals are [0.17, 0.24] (please correct me if I am…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

KeyError while printing trace in PyMC

I had read that by default some names are assigned to Stochastic vaiables. I am writing the relevant portion of my code below. lam = pm.Uniform('lam', lower=0.0, upper=5, doc='lam') parameters = pm.Dirichlet('parameters',[1,1,1,1],…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

Improve the speed of loop performance

I am trying to build a sample for my Markov chain Monte Carlo code using pyMC. So with the sampled parameters of the model, each time the output is built by calling getLensing instance from nfw class and compared to the observed data. My problem is…
Dalek
  • 4,168
  • 11
  • 48
  • 100
0
votes
1 answer

Recursive Bayesian with pymc

In general bayesian inference works like: prior = foo for data in (dataSet as it arrives): posterior = prior+model+data prior = posterior The amazing pakedge PyMC seems to have the workflow: prior = foo run MCMC on…
Jacob
  • 1,423
  • 16
  • 29
0
votes
1 answer

MAP in PyMC is giving unexpected error

I don't understand why MAP is giving error where as MCMC works fine in the same scenario? I am writing below the relevant part of code. tau = Uniform('tau', lower=0.01, upper=5, doc='tau') rv = [ Multinomial("rv"+str(i), count[i],…
turing
  • 577
  • 1
  • 4
  • 12