Skip to content

Instantly share code, notes, and snippets.

View maxdevblock's full-sized avatar
☮️
peace, no war

MaxDevBlock maxdevblock

☮️
peace, no war
View GitHub Profile
@sergiosonline
sergiosonline / stan_demo.py
Created January 20, 2020 16:10
Jupyter Notebook accompanying "Painless Introduction to Applied Bayesian Inference Using PyStan"
#!/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:
@jhconning
jhconning / jsonread.ipynb
Last active April 3, 2021 08:45
json into a dataframe with normalize
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhconning
jhconning / cKDTree.ipynb
Last active April 3, 2021 08:41
cKDTree spatial example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rudeboybert
rudeboybert / modeling_with_data_tidyverse.R
Last active April 16, 2024 18:16
R source code for "Modeling with Data in the Tidyverse" DataCamp course
# 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)
@kgori
kgori / discretize.py
Last active October 11, 2020 11:54
How to discretize a gamma or lognormal distribution, for modelling rates over sites in a phylogenetic model
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)