Skip to content

Instantly share code, notes, and snippets.

View stephenjbarr's full-sized avatar

Stephen Jeffrey Barr stephenjbarr

View GitHub Profile
@stephenjbarr
stephenjbarr / use_ddg.py
Created June 26, 2015 07:02
Find images from a string using Duck Duck Go's API
{
"metadata": {
"name": "",
"signature": "sha256:a1d46d6db61857a10a811537203ce4f5bea4db915cb1fbd2fc9835b10e6c2a35"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@stephenjbarr
stephenjbarr / test_csv_parse.cpp
Created March 31, 2012 17:22
using boost tokenizer to parse CSV files into Eigen Matrices
#include <iostream>
#include <iomanip>
#include <fstream>
#include "mkl.h"
#include "math.h"
#include <vector>
#include <cmath>
#include <string>
#include <cstdlib>
@stephenjbarr
stephenjbarr / sjb-subsettest.cpp
Created April 5, 2012 16:14
playing with subsetting in Eigen
#include <iostream>
#include <iomanip>
#include <fstream>
#include "mkl.h"
#include "math.h"
#include <vector>
#include <cmath>
#include <string>
@stephenjbarr
stephenjbarr / test.R
Created April 6, 2012 17:43
Here is my trended R code to plot trended vs detrended data
## Stephen J. Barr
## - this is some practice retrending the model
setwd("/home/stevejb/myhg/is-solver/indep_sim/")
retrendDemo <- function(THETA = 0.7880) {
## produce initial values
x = rnorm(30, sd=.03)
@stephenjbarr
stephenjbarr / sjb_nll_optim.cc
Created August 30, 2012 02:13
attempt at MPI optimizaer
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// SJB - first shot at RInside and Eigen combined
//
// Copyright (C) 2012 Stephen J. Barr
//
// GPL'ed
#include <iostream>
@stephenjbarr
stephenjbarr / sjb_mpi.cc
Created August 30, 2012 04:17
why does the MPI section fail
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// SJB - first shot at RInside and Eigen combined
//
// Copyright (C) 2012 Stephen J. Barr
//
// GPL'ed
#include <iostream>
@stephenjbarr
stephenjbarr / Makefile
Created August 30, 2012 06:25
A few demonstrations of Rcpp::InternalFunction
## -*- mode: make; tab-width: 8; -*-
##
## Simple Makefile
##
## From RInside examples
## TODO:
## proper configure for non-Debian file locations, [ Done ]
## allow RHOME to be set for non-default R etc
## comment this out if you need a different version of R,
@stephenjbarr
stephenjbarr / mpi_something.cpp
Created September 7, 2012 20:06
mpi something
/////////////////////
// THE MPI SECTION //
/////////////////////
MPI::Init();
// Next, use GSL to optimize over this
nll_mpi(start_vector, ua, ub, Xmat, Ymat, TASK_PARAM, false);
VectorXd test_vector = start_vector;
double INCREMENT = 0.1;
double my_result;
clear all; close all; clc
%% Exercise 3-1A
% find reasonable best-fit polynomial for data1 and data2
data1 = load('data1.txt');
data2 = load('data2.txt');
data3 = load('data3.txt');
public void updateStats(double dt)
{
if(TNOW>endTime*warmUp)
{
double totalinsystemdt = serversLevels[1].size()+2*serversLevels[2].size()+3*serversLevels[3].size()+4*serversLevels[4].size()+queueVector.size();
//if(TNOW>9950){
//System.out.println("-----------------------");
//System.out.println("Time elapsed: " +dt);
//System.out.println("Z1: "+serversLevels[1].size()+" Z2: "+serversLevels[2].size()+" Z3: "+serversLevels[3].size()+" Z4: "+serversLevels[4].size()+" Q: "+queueVector.size()+ " Total: "+totalinsystemdt);