This notebook is a work in progress.

In [1]:
from __future__ import division, print_function
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
/home/cgranade/anaconda/envs/qinfer-binder/lib/python3.5/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))
In [2]:
from qinfer.test_models import SimplePrecessionModel
from qinfer.derived_models import RandomWalkModel
from qinfer.distributions import NormalDistribution, UniformDistribution
from qinfer.smc import SMCUpdater
/home/cgranade/anaconda/envs/qinfer-binder/lib/python3.5/site-packages/qinfer/metrics.py:51: UserWarning: Could not import scikit-learn. Some features may not work.
  warnings.warn("Could not import scikit-learn. Some features may not work.")
/home/cgranade/anaconda/envs/qinfer-binder/lib/python3.5/site-packages/IPython/parallel.py:13: ShimWarning: The `IPython.parallel` package has been deprecated. You should import from ipyparallel instead.
  "You should import from ipyparallel instead.", ShimWarning)
/home/cgranade/anaconda/envs/qinfer-binder/lib/python3.5/site-packages/qinfer/parallel.py:53: UserWarning: Could not import IPython parallel. Parallelization support will be disabled.
  "Could not import IPython parallel. "
In [3]:
prior = UniformDistribution([0, 1])
step_dist = NormalDistribution(0, 0.01**2)
In [4]:
model = RandomWalkModel(SimplePrecessionModel(), step_dist)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-3c9aae59703f> in <module>()
----> 1 model = RandomWalkModel(SimplePrecessionModel(), step_dist)

/home/cgranade/anaconda/envs/qinfer-binder/lib/python3.5/site-packages/qinfer/derived_models.py in __init__(self, underlying_model, step_distribution)
    362         self._step_dist = step_distribution
    363 
--> 364         if self._model.n_modelparams != self._step_dist.n_rvs:
    365             raise TypeError("Step distribution does not match model dimension.")
    366 

AttributeError: 'RandomWalkModel' object has no attribute '_model'
In [5]:
updater = SMCUpdater(model, 1000, prior)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-e569019cded6> in <module>()
----> 1 updater = SMCUpdater(model, 1000, prior)

NameError: name 'model' is not defined
In [6]:
experiments = np.logspace(-2, 4, 200)
true_model = prior.sample()
for idx_exp, experiment in enumerate(experiments):
    outcome = model.simulate_experiment(true_model, experiment[np.newaxis])
    updater.update(outcome, experiment[np.newaxis])
    
print true_model, updater.est_mean()
  File "<ipython-input-6-4854be25e774>", line 7
    print true_model, updater.est_mean()
                   ^
SyntaxError: invalid syntax