Skip to content

Instantly share code, notes, and snippets.

View sdwfrost's full-sized avatar

Simon Frost sdwfrost

View GitHub Profile
@sdwfrost
sdwfrost / ModelingWithJulia.ipynb
Last active August 17, 2017 11:48
Some examples of mathematical modeling and simple MCMC in Julia
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sdwfrost
sdwfrost / ModelingWithR.ipynb
Created January 16, 2014 13:17
Some examples of mathematical modeling and simple MCMC in R, including some Rcpp examples
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sdwfrost
sdwfrost / sir_example.html
Last active August 29, 2015 13:56
An example of an SIR epidemiological model in Agentscript
<html>
<head>
<title>SIR Model</title>
<script src="http://agentscript.org/lib/agentscript.js"></script>
<script src="http://agentscript.org/tools/coffee-script.js"></script>
<script type="text/coffeescript">
u = ABM.util # ABM.util alias, u.s is also ABM.shapes accessor.
log = (arg) -> console.log arg
class MyModel extends ABM.Model
@sdwfrost
sdwfrost / nyjazz.txt
Last active August 29, 2015 14:02
Processing RDS data
ID netsize mycoupon coupon1 coupon2 coupon3 coupon4 coupon5 coupon6 coupon7 coupon8 gender.mf age airplay.yn
1 350 0 14250004 14250005 14250006 14256002 0 0 0 901 1 40 1
2 0 0 14250007 14250008 14250009 14256003 0 0 912 902 1 64 1
3 585 0 14250010 14250011 14250012 14256004 0 0 0 903 2 41 1
4 400 0 14250025 14250026 14250027 14256009 0 0 0 904 2 77 0
5 150 0 14250022 14250023 14250023 14256008 0 0 0 905 1 33 1
6 100 0 14250028 14250029 14250030 14256010 0 0 916 906 1 31 2
7 300 0 14250016 14250017 14250018 14256006 0 0 0 907 1 70 1
8 700 0 14250040 14250041 14250042 14256014 0 0 0 908 1 49 1
9 300 14256002 14250013 14250014 14250015 14256005 0 0 0 909 2 38 1
@sdwfrost
sdwfrost / marglike.Rmd
Last active August 29, 2015 14:02
Marginal likelihoods via power posteriors and stepping stones in R
Under the Bayesian paradigm, inference is based on the posterior probability over the parameters of interest. It's helpful to think of our inferences being conditional on a given model, $M$ with a parameter vector $\theta \in \Theta$. Given a dataset, $D$, and a model, the posterior distribution of the parameter values is given by Bayes' theorem.
\[
\begin{align}
Pr(\theta|D,M) = \frac{Pr(D|\theta,M)Pr(\theta|M)}{Pr(D|M)}
\end{align}
\]
$Pr(D|\theta,M)$ is the likelihood function, $Pr(\theta|M)$ is the prior probability , and $Pr(D|M)$ is known as the marginal likelihood, predictive probability, or evidence. $Pr(D|M)$ is a normalising constant that ensures that $Pr(\theta|D,M)$ is a probability.
@sdwfrost
sdwfrost / marginal_likelihood_in_julia.ipynb
Created June 24, 2014 19:54
Marginal likelihood in Julia
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sdwfrost
sdwfrost / hellobeagle.jl
Last active July 26, 2016 02:49
Example of using the BEAGLE library in Julia
@printf "BEAGLE version %s" bytestring(ccall((:beagleGetVersion,"libhmsbeagle"), Ptr{Cchar}, (),))
@printf "BEAGLE citation %s" bytestring(ccall((:beagleGetCitation,"libhmsbeagle"), Ptr{Cchar}, (),))
const BEAGLE_OP_COUNT = 7
const BEAGLE_OP_NONE = -1
immutable BeagleResource
name::Ptr{Uint8}
@sdwfrost
sdwfrost / hellobeagle.ipynb
Last active August 29, 2015 14:19
hellobeagle.jl as an IJulia notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sdwfrost
sdwfrost / vill.phy
Created May 2, 2015 16:48
Training datasets for PANGEA village simulations
This file has been truncated, but you can view the full file.
984 6987
HOUSE2308_11180 atgggtgcga gagcgtcaat attaagaagg ggaaaattag atacgtggga aaaaattagg
HOUSE1092_16633 atgggtgcga gagcgtcaat attaagaagg ggaaaaatag atacgtggga aaaaattagg
HOUSE3776_6969 atgggtgcga gagcgtcaat attaagaggg ggaaaattag atacatggga aaaaattaag
HOUSE660_14791 atgggtgcga gagcgtcaat attaaggtgg ggaaaactag atacatggga aaaaattaag
HOUSE1492_11556 atgggtgcga gagcgtcaat attaaggtgg ggaaaattag atacatggga aaaaattaag
HOUSE713_15113 atgggtgcga gagcgtcaat attaaggtgt ggaaaattag atacatggga aaaaattaag
HOUSE4256_16741 atgggtgcga gagcgtcaat attaaggtgt ggaaaattag atacatggga aaaaattaag
HOUSE2116_7615 atgggtgcga gagcgtcaat attaaggtgt ggaaaattag atacatggga aaaaattaag
HOUSE345_9899 atgggtgcaa gagcgtcaat attaagagga ggaaaattag atacatgtaa aaaaattagg
@sdwfrost
sdwfrost / hello.fas
Created May 5, 2015 09:56
Sequence file for use with hellobeagle.ipynb
>mars
CCGAG-AGCAGCAATGGAT-GAGGCATGGCG
>saturn
GCGCGCAGCTGCTGTAGATGGAGGCATGACG
>jupiter
GCGCGCAGCAGCTGTGGATGGAAGGATGACG