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
simDSLogistic=function(K,r,N0){ | |
# Unusually, for this model, we know the number of events a priori | |
eventNo=K-N0 | |
# So we can just generate all required random numbers (quickly) in one go | |
unifs=runif(eventNo) | |
# Every event produces one cell and consumes one unit of nutrients | |
clist=(N0+1):K | |
# Simulate time between events by generating | |
# exponential random numbers using the inversion method | |
dts=-log(1-unifs)/(r*clist*(1-clist/K)) |
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
import numpy as np | |
def simDSLogistic(K,r,N0): | |
'''Discrete stochastic logistic model simulation. Carrying capacity K, | |
intrinsic growth rate r, initial population size (inoculum) N0. Returns an | |
array with a (continuous) time column and a (discrete) population size column.''' | |
# Unusually, for this model, we know the number of events a priori | |
eventNo=K-N0 | |
# So we can just generate all required random numbers (quickly) in one go | |
unifs=np.random.uniform(size=eventNo) |
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
########### | |
# Optimum circle packing in R | |
########### | |
# Function closure, sets up list of possible combinations | |
# and returns objective function | |
createObj<-function(N,W,H){ | |
print("Generating combinations...") | |
# Generate all possible circle pairings |
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(DEoptim) | |
library(rgenoud) | |
library(snow) | |
# CirclePacking.R from https://gist.github.com/4571810 | |
source("CirclePacking.R") | |
# Number of circles and dimensions of bounding rectangle | |
N=100; W=10; H=10 | |
root="N64_100" |
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
import random, numpy | |
def genGuess(N,W,H): | |
'''Generate sensible initial guess vector (random circle coordinates and radii)''' | |
z=numpy.zeros(3*N) | |
for i in xrange(0,N): | |
z[i*3]=random.random()*W | |
z[i*3+1]=random.random()*H | |
z[i*3+2]=0.001*min(W,H)+random.random()*(0.009*min(W,H)) | |
return(z) |
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
# Simulating n steps of a biased random walk | |
# starting from x0 and with decreasing steps | |
# occurring with probability theta | |
randomWalk=function(n=100,x0=0,theta=0.5){ | |
x=x0 | |
res=array(x0,dim=n+1) | |
unifs=runif(n) | |
for(i in 0:(n-1)){ | |
if (unifs[i+1]<=theta){x=x-1}else{x=x+1} | |
res[i+2]=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
simCellsHybrid=function(K,r,N0,NSwitch,detpts=100){ | |
# Every event produces one cell and consumes one unit of nutrients | |
if(NSwitch>N0){ | |
# Unusually, for this model, we know the number of events a priori | |
eventNo=NSwitch-N0 | |
# So we can just generate all required random numbers (quickly) in one go | |
unifs=runif(eventNo) | |
clist=(N0+1):NSwitch | |
# Time between events | |
dts=-log(1-unifs)/(r*clist*(1-clist/K)) |
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
from colonyzer2 import * | |
import time, sys | |
def main(fmt="384"): | |
# Lydall lab file naming convention | |
# First 15 characters in filename identify unique plates | |
# Remaining charaters can be used to store date, time etc. | |
barcRange=(0,15) | |
if len(sys.argv)>1: | |
fmt=sys.argv[1] |
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
import pygame, os, sys | |
from pygame.locals import * | |
# Runs through all jpgs in current directory | |
# Opens each in turn, allowing user to click on image features | |
# Left clicking draws a red dot, right-clicking draws a yellow dot | |
# Press q or esc to move to next image | |
# Once an image is finished, a version with click locations overlaid is saved to file | |
# Numbers of left and right clicks are embedded into filename |
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
import winsound, time, Tkinter | |
slides=[] | |
cells=[0,0,0] | |
labels=["G1","S","G2/M"] | |
print "Slide: %02d"%(len(slides)+1) | |
def key(event): | |
if event.char=="g": | |
cells[0]+=1 |
OlderNewer