Skip to content

Instantly share code, notes, and snippets.

View ahartikainen's full-sized avatar

Ari Hartikainen ahartikainen

View GitHub Profile
@ahartikainen
ahartikainen / pystan_fit_to_xarray.ipynb
Created May 29, 2018 14:03
Export PyStan fit object to xarray
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from datetime import datetime
def hetu(date, gender):
"""
hetu(date, gender)
Parameters
----------
date : datetime.datetime object
gender : str {'male', 'female'}
# Running times
[success] 13.95% test_stan_file_io.TestStanFileIO.test_stan_model_from_file: 80.9590s
[success] 13.32% test_pickle.TestPickle.test_model_unique_names: 77.2730s
[success] 8.18% test_extra_compile_args.TestExtraCompileArgs.test_extra_compile_args: 47.4787s
[success] 7.81% test_chains.TestRhatZero.test_rhat_zero: 45.3319s
[success] 7.09% test_pickle.TestPickle.test_pickle_model_and_reload: 41.1400s
[success] 6.97% test_rstan_getting_started.TestRStanGettingStarted.test_stan_file: 40.4583s
[success] 6.93% test_rstan_stan_args.TestPyStanArgs.test_stan_args_basic: 40.1854s
[success] 6.87% test_pickle.TestPickle.test_pickle_fit: 39.8326s
# disable visual plots
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
import pystan
from scipy.stats.distributions import cauchy, norm, t as student_t
import arviz as az
import pickle
import gzip
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahartikainen
ahartikainen / PyStan_download_stats.ipynb
Last active January 26, 2019 23:00
Get stats for PyStan
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahartikainen
ahartikainen / adhoc_edge_correction.ipynb
Last active January 28, 2019 10:00
Adhoc edgecorrections for Scipy gaussian_kde
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahartikainen
ahartikainen / prior_and_posterior.ipynb
Last active February 22, 2019 01:22
Simple example on PyStan
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahartikainen
ahartikainen / stan_example.ipynb
Created April 23, 2019 19:37
Stan Example Models
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.