Tuesday, November 30, 2010

cat is for concatenate (tfw?)

I always forget how to use the cat utility. Here's how.

Monday, November 29, 2010

Lotka-Volterra Predator-Prey Model in Three Part Harmony

#!/usr/bin/env python

import os

def system( u, v, w, uinit, vinit, winit, time ):
ut = list(); ut.append( uinit )
vt = list(); vt.append( vinit )
wt = list(); wt.append( winit )
for i in range( time ):
ut.append( u.update( ut[-1], vt[-1], wt[-1] ) )
vt.append( v.update( vt[-1], ut[-1], wt[-1] ) )
wt.append( w.update( wt[-1], ut[-1], vt[-1] ) )
return ( ut, vt, wt )

class Component:
def __init__( self, a, b, g, h ):
self.alpha = a
self.beta = b
self.gamma = g
self.step = h
def update( self, x, y, z ):
self.body = self.alpha*x + self.beta*x*y + self.gamma*x*z
return x + self.step*self.body

step = 0.08
u = Component( -1.0, 0.025, 0.035, step )
v = Component( 1.5, -0.45, -0.024, step )
w = Component( 1.45, -0.75, 0.026, step )
( ut, vt, wt ) = system( u, v, w, 5.0, 50.0, 20.0, 4000 )

ubuff = open( "ut.txt", "w" )
vbuff = open( "vt.txt", "w" )
wbuff = open( "wt.txt", "w" )

for i in range( len( ut ) ):
ubuff.write( str( ut[i] ) )
ubuff.write('\n')
vbuff.write( str( vt[i] ) )
vbuff.write('\n')
wbuff.write( str( wt[i] ) )
wbuff.write('\n')

ubuff.close(); vbuff.close(); wbuff.close()

foo = list()
foo.append('#!/usr/bin/env octave\n')
foo.append('\n')
foo.append('load ut.txt ; load vt.txt ; load wt.txt ;\n')
foo.append('t = 0:4000 ; plot( t, ut, t, vt, t, wt ) ;\n')
foo.append('print -djpeg foo.jpeg;\n')

f = open( "foo.o", "w" )
f.writelines( foo )
f.close()

os.system( 'octave -qf foo.o' )
os.system( 'evince foo.jpeg &' )

os.system( 'rm ut.txt' )
os.system( 'rm vt.txt' )
os.system( 'rm wt.txt' )
os.system( 'rm foo.o' )

Wednesday, November 24, 2010

Robot Scientist

A robot scientist, here.

Genetic algorithm equation maker, here.

"Distilling Free-Form Natural Laws from Experimental Data." By Michael Schmidt and Hod Lipson. Science, Vol. 324, April 3, 2009.

"Automating Science." By David Waltz and Bruce Buchanan. Science, Vol. 324, April 3, 2009.

Pthreads!

A good introductory tutorial to pthreads can be found here.

Thursday, November 18, 2010

Sanderson and Croft, Deriving Concept Hierarchies from Text

Monothetic clusters: membership is based only on one feature.

Polythetic clusters: a document's membership to a given cluster is defined by its possession of a sufficient fraction of terms from that cluster. See Scatter/Gather.

The topic of a monothetic cluster is usually more intuitive than the topic of a polythetic cluster.

Five basic principles:
1) Terms in hierarchy extracted from documents, and reflect topics covered in documents

Wednesday, November 10, 2010

Color Schemes

Kuler?

Misc Linux Commands

Commands found, here, banner and cal are pretty neat.

GPU Gems 2

Book available in HTML format, here.

Friday, November 5, 2010

GPGPU Shtuff

Supercomputing for the Masses can be found, here.

Monday, November 1, 2010

stdint.h with g++ on Ubuntu

The header file stdint.h, needed for larger integer types, has at line 24:

#include

but on Ubuntu you need to change this to:

#include