pymc

Survival analysis in PyMC 3

孤者浪人 提交于 2019-11-30 14:15:34
I tried to port simple survival model from here (the first one in introduction) form PyMC 2 to PyMC 3. However, I didn't find any equivalent to "observed" decorator and my attempt to write a new distribution failed. Could someone provide an example how is this done in PyMC 3? This is a tricky port, and requires three new concepts: Use of the theano tensor Use of the DensityDist Passing a dict as observed This code provides the equivalent model as the PyMC2 version you linked to above: import pymc3 as pm from pymc.examples import melanoma_data as data import theano.tensor as t times = data.t #

Custom likelihood in pymc3

痴心易碎 提交于 2019-11-30 14:06:27
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). For example, following code does not work: from pymc import * with Model() as model: x = Normal('x', 1, 1) def z(u): if u > 0: #comparisons like this are not supported # if theano.tensor.lt(0,u): this is how comparison should be done return u ** 2 return -u**3 x2 = Potential('x2', z(x)) start = model.test_point h = find_hessian(start) step =

pymc3 : Multiple observed values

夙愿已清 提交于 2019-11-30 00:56:35
I have some observational data for which I would like to estimate parameters, and I thought it would be a good opportunity to try out PYMC3. My data is structured as a series of records. Each record contains a pair of observations that relate to a fixed one hour period. One observation is the total number of events that occur during the given hour. The other observation is the number of successes within that time period. So, for example, a data point might specify that in a given 1 hour period, there were 1000 events in total, and that of those 1000, 100 were successes. In another time period,

pymc3 : Multiple observed values

馋奶兔 提交于 2019-11-28 21:40:02
问题 I have some observational data for which I would like to estimate parameters, and I thought it would be a good opportunity to try out PYMC3. My data is structured as a series of records. Each record contains a pair of observations that relate to a fixed one hour period. One observation is the total number of events that occur during the given hour. The other observation is the number of successes within that time period. So, for example, a data point might specify that in a given 1 hour

How to model a mixture of 3 Normals in PyMC?

雨燕双飞 提交于 2019-11-28 03:14:20
问题 There is a question on CrossValidated on how to use PyMC to fit two Normal distributions to data. The answer of Cam.Davidson.Pilon was to use a Bernoulli distribution to assign data to one of the two Normals: size = 10 p = Uniform( "p", 0 , 1) #this is the fraction that come from mean1 vs mean2 ber = Bernoulli( "ber", p = p, size = size) # produces 1 with proportion p. precision = Gamma('precision', alpha=0.1, beta=0.1) mean1 = Normal( "mean1", 0, 0.001 ) mean2 = Normal( "mean2", 0, 0.001 )

Incremental model update with PyMC3

你说的曾经没有我的故事 提交于 2019-11-27 21:39:36
Is it possible to incrementally update a model in pyMC3. I can currently find no information on this. All documentation is always working with a priori known data. But in my understanding, a Bayesian model also means being able to update a belief. Is this possible in pyMC3? Where can I find info in this? Thank you :) Following @ChrisFonnesbeck's advice, I wrote a small tutorial notebook about incremental prior updating. It can be found here: https://github.com/pymc-devs/pymc3/blob/master/docs/source/notebooks/updating_priors.ipynb Basically, you need to wrap your posterior samples in a custom

Solving inverse problems with PyMC

五迷三道 提交于 2019-11-27 14:22:48
问题 Suppose we're given a prior on X (e.g. X ~ Gaussian) and a forward operator y = f(x) . Suppose further we have observed y by means of an experiment and that this experiment can be repeated indefinitely. The output Y is assumed to be Gaussian (Y ~ Gaussian) or noise-free (Y ~ Delta(observation)). How to consistently update our subjective degree of knowledge about X given the observations? I've tried the following model with PyMC, but it seems I'm missing something: from pymc import * xtrue = 2

Install anaconda library from a local source

。_饼干妹妹 提交于 2019-11-27 13:06:57
问题 I have been trying to install pymc for some time on a Windows PC behind a very complicated proxy; effectively making this an installation on a computer not connected to the internet. I have tried - unsuccessfully - to set a proxy in the condarc file but I still get error messages conda install -c https://conda.binstar.org/pymc pymc Fetching package metadata: SSL verification error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645) 回答1: To solve this, you need to download

Fit a non-linear function to data/observations with pyMCMC/pyMC

旧街凉风 提交于 2019-11-27 11:14:57
I am trying to fit some data with a Gaussian (and more complex) function(s). I have created a small example below. My first question is, am I doing it right? My second question is, how do I add an error in the x-direction, i.e. in the x-position of the observations/data? It is very hard to find nice guides on how to do this kind of regression in pyMC. Perhaps because its easier to use some least squares, or similar approach, I however have many parameters in the end and need to see how well we can constrain them and compare different models, pyMC seemed like the good choice for that. import

Incremental model update with PyMC3

[亡魂溺海] 提交于 2019-11-26 20:45:05
问题 Is it possible to incrementally update a model in pyMC3. I can currently find no information on this. All documentation is always working with a priori known data. But in my understanding, a Bayesian model also means being able to update a belief. Is this possible in pyMC3? Where can I find info in this? Thank you :) 回答1: Following @ChrisFonnesbeck's advice, I wrote a small tutorial notebook about incremental prior updating. It can be found here: https://github.com/pymc-devs/pymc3/blob/master