Skip to content

Instantly share code, notes, and snippets.

View floswald's full-sized avatar
👋

Florian Oswald floswald

👋
View GitHub Profile
#
#
# To build a target, enter:
#
# make <target>
#
# Targets:
#
# all - builds exe, dbg
# clean - deletes all .o, .a, binaries, in source/ directory
@floswald
floswald / julia_nim_cpp_r_sir.md
Created April 24, 2020 15:24 — forked from sdwfrost/julia_nim_cpp_r_sir.md
Comparing simple simulations in Julia, Nim, C++ and R

This gist compares the performance of Julia, Nim, C++ and R - the latter using either POMP, or LibBi in a simple simulation of an SIR epidemiological model. In addition to keeping track of susceptibles, infecteds and recovereds, I also store the cumulative number of infections. Time moves in discrete steps, and the algorithm avoids language-specific syntax features to make the comparison as fair as possible, including using the same algorithm for generating binomial random numbers and the same random number generator; the exception are the R versions, POMP uses the standard R Mersenne Twister for the random number generator; I'm not sure what LibBi uses. The algorithm for generating random binomial numbers is only really suitable for small np.

Benchmarks were run on a Mac Pro (Late 2013), with 3 Ghz 8-core Intel Xeon E3, 64GB 1866 Mhz RAM, running OSX v 10.11.3 (El Capitan

acs_catcher <- function(tbl, state, year=2017 ){
done = FALSE
while(!done){
out <- tryCatch(
{
x = get_acs(geography = "tract", state = state, table = tbl, year = year,keep_geo_vars = TRUE,cache_table = TRUE)
done = TRUE
return(x)
},
error = function(e) {
using BasisMatrices, Optim, QuantEcon, Parameters
using BasisMatrices: Degree, Derivative
using Printf, Random
using LinearAlgebra
"""
The stochastic Neoclassical growth model type contains parameters
which define the model
@floswald
floswald / ravallion.R
Created November 29, 2018 08:57
I think this is what you did.
# download data
download.file("http://microdata.worldbank.org/index.php/catalog/428/download/28457","~/Downloads/data.zip")
unzip("~/Downloads/data.zip")
# read data
library(data.table)
x = fread("Downloads/edattainxtry_1.csv")
d = x[,list(year,country,aAll_6,aQuint1x_6,aQuint5x_6)]
# plot data
@floswald
floswald / #Prob_View.txt
Created September 8, 2018 20:25 — forked from calpolystat/#Prob_View.txt
Probability Distribution Viewer: Shiny app at http://www.statistics.calpoly.edu/shiny
Probability Distribution Viewer Shiny App
Base R code created by Irvin Alcaraz
Shiny app files created by Irvin Alcaraz
Cal Poly Statistics Dept Shiny Series
http://statistics.calpoly.edu/shiny
@floswald
floswald / remarkjs.css
Created August 23, 2018 14:23 — forked from fladd/remarkjs.css
CSS of the example slides on http://remarkjs.com
@import url(https://fonts.googleapis.com/css?family=Droid+Serif);
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body {
font-family: 'Droid Serif';
}
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: 400;

Keybase proof

I hereby claim:

  • I am floswald on github.
  • I am floswald (https://keybase.io/floswald) on keybase.
  • I have a public key whose fingerprint is 07C0 B518 D738 3F47 01B0 FAEC 717D 527B 629B 41B8

To claim this, I am signing this object:

# context: http://stackoverflow.com/questions/39448808/julia-tcp-server-and-connection
# Use fn to process messages from sock.
# Loop till sock is open and fn returns true.
function processor(fn, sock)
proc = true
try
while proc && ((nb_available(sock) > 0) || isopen(sock))
proc = fn(sock)
end
static double adraw (struct aspacestruct *aspace)
{ /*returns the next value in the stream of guesses of A
terminates the sequence by sending -INFINITY
*/
double aa,bb,mstep,astep,upper;
int i;
aspace[0].ncalls+=1.0;
if (aspace[0].ncalls>=ngridmax)
{