This file contains 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 <iostream> | |
using namespace std; | |
class CSingleton final | |
{ | |
public: | |
static CSingleton* GetInstance(); | |
void set_x(const int& x_){x = x_;}; | |
int get_x(){return x;}; |
This file contains 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
SEXP call_function(SEXP call, SEXP rho){ | |
/* advance to 2nd element (CAR) of call pairlist; 1st element is just the call_function function */ | |
SEXP args = CDR(call); | |
/* get function (2rd element) and advance to 3th element */ | |
SEXP funSymbol = install("FUN"); | |
args = CDR(args); | |
/* make the function call */ |
This file contains 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
/* ################################################################################ | |
* BEGIN UTILITY FUNCTIONS | |
################################################################################ */ | |
#define NONEMPTY_(_FRAME_) \ | |
CHAR(PRINTNAME(TAG(_FRAME_)))[0] != '.' && CAR(_FRAME_) != R_UnboundValue | |
static int FrameSize(SEXP frame, int all) | |
{ | |
int count = 0; |
This file contains 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 |
This file contains 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 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 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 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 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 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++) |