Skip to content

Instantly share code, notes, and snippets.

View dododas's full-sized avatar

Raibatak Das dododas

  • Seattle, WA, USA
View GitHub Profile
@dododas
dododas / random-walk-1.pde
Last active March 15, 2016 04:17
Particles performing Brownian random walk - processing
// processing script to simulate Brownian random motion
int n_particles = 200; // number of particles
// prepare arrays to store particle coordinates
float[] x = new float[n_particles];
float[] y = new float[n_particles];
void setup() {
size(512, 512);
@dododas
dododas / computeDmle.R
Last active February 2, 2016 17:36
Maximum likelihood diffusion coefficient calculation for single particle tracks
# Estimate per-step and per-trajectory diffusion coefficients from SPT data
#
# Created by: Raibatak Das
# Jan 2016
library(readxl)
library(dplyr)
# Function to compute per-step diffusion coefficients
singlestepDmle = function(frame, x, y, pxl, dt){
@dododas
dododas / birthdayMC.R
Last active March 9, 2017 08:14
Monte Carlo simulation for a non-standard birthday problem
# Monte Carlo simulation to compute the probability that in a random sample of
# 50 individuals, 4 share a birthday and the other 46 have distinct birthdays
bdayOneTrial = function(){
# Simulate a single trial
bdays = sample.int(365, size=50, replace=T)
counts = as.data.frame(table(bdays))
sorted.counts = sort(counts$Freq, decreasing=T)
success = sorted.counts[1]==4 && sorted.counts[2]==1
return(success)
@dododas
dododas / logseq.py
Last active November 1, 2015 04:25
Python generator for the sequence 1, 2,.., 9, 10, 20,.., 90, 100, 200,..,.
#!/usr/bin/env python3
'''
A python generator for the sequence 1, 2,.., 9, 10, 20,.., 90, 100, 200,.. up to n_max
Created by: Raibatak Das
'''
from math import floor, log10
def logseq(n_max):