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
/* evaluate 2 functions with ... (but must take same named args) */ | |
SEXP C_example(SEXP call, SEXP rho){ | |
SEXP args = CDR(call); | |
/* make up some 'arguments' for our two functions we want to call */ | |
SEXP a1 = PROTECT(allocVector(REALSXP,1)); | |
SEXP b1 = PROTECT(allocVector(REALSXP,1)); | |
REAL(a1)[0] = 5.; | |
REAL(b1)[0] = 10.; |
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
get_omega1 <- function(mu,lifespanReduction){ | |
lifespan <- (1/mu) * lifespanReduction | |
get_omega_f <- function(omega,mu,lifespan){ | |
(1/(1-omega+(omega*mu)))-lifespan | |
} | |
return(uniroot(f=get_omega_f,interval=c(0,1),lifespan=lifespan,mu=mu,maxiter=1e4)$root) | |
} | |
# 10-25-2018 | |
get_omega <- function(mu,lifespan){ |
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
#include <Rcpp.h> | |
#include <random> | |
#include <vector> | |
using namespace Rcpp; | |
// [[Rcpp::plugins(cpp11)]] | |
typedef std::mt19937 RNG; |
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
// CPP program to find harmonic mean of numbers. | |
#include <bits/stdc++.h> | |
using namespace std; | |
template <typename T> | |
float harmonicMean(T arr[], int n){ | |
// Declare sum variables and initialize | |
// with zero. | |
float sum = 0; | |
for (int i = 0; i < n; i++) |
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
library(viridis) | |
library(spatstat) | |
library(truncdist) | |
# source: https://github.com/slwu89/PlosCompBio_2013/blob/master/fig2/code/functionsModel.R | |
points.clustered = function(n, meanParents = 10, clusteredness = .25, ...){ | |
meanDist = clusteredness / sqrt(meanParents) | |
meanChildren = n / meanParents | |
ps = rMatClust(meanParents, meanDist, meanChildren, ...) | |
while(ps$n != n){ |
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
\documentclass[12pt]{article} | |
\usepackage{pgf} | |
\usepackage{tikz} | |
\usetikzlibrary{arrows,automata} | |
\usepackage[latin1]{inputenc} | |
\begin{document} | |
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, | |
semithick] |
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
#ifndef human_hpp | |
#define human_hpp | |
#include <stdio.h> | |
#include <iostream> | |
#include <string> | |
#include <random> | |
#include <functional> | |
#include <map> | |
using namespace std::placeholders; |
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
library(deSolve) | |
mod <- function(t,y,par){ | |
with(as.list(c(y,par)),{ | |
# lagged state variables | |
if((t - TO) < 0){ | |
S_TO <- S_init |
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
n_iter = 100 | |
n_nodes = 10 | |
trace = vector(mode="list",length = n_iter) | |
trace[[1]] = sample(x = 1:n_nodes,size = n_nodes,replace = TRUE) | |
for(i in 2:n_iter){ | |
trace[[i]] = trace[[i-1]] | |
j = sample(x = 1:n_nodes,size = 1) # sample index | |
trace[[i]][j] = sample(x = 1:n_nodes,size = 1) # flip n-bit | |
} |
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
events = c( | |
birth = 1/1.5, | |
death = 1/2.5 | |
) | |
state = c( | |
animals = 5 | |
) | |
tmax = 1e3 |