This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# # Intro to PyStan | |
# Stan is a computation engine for Bayesian model fitting. It relies on HMC to sample from the posterior distribution of the desired model. | |
# | |
# Here are the detailed installation steps to set up Stan: https://pystan.readthedocs.io/en/latest/installation_beginner.html | |
# | |
# For MacOS: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# R source code for all slides/videos in Albert Y. Kim's "Modeling with Data in | |
# the Tidyverse" DataCamp course: | |
# https://www.datacamp.com/courses/modeling-with-data-in-the-tidyverse | |
# This code is available at http://bit.ly/modeling_tidyverse | |
# Load all necessary packages ----- | |
library(ggplot2) | |
library(dplyr) | |
library(moderndive) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy | |
import scipy.stats as ss | |
import numpy as np | |
def discretize(alpha, ncat, dist=ss.gamma): | |
if dist == ss.gamma: | |
dist = dist(alpha, scale=1 / alpha) | |
elif dist == ss.lognorm: | |
dist = dist(s=alpha, scale=np.exp(0.5 * alpha**2)) | |
quantiles = dist.ppf(np.arange(0, ncat) / ncat) |