# computer

### Variable probability Bernoulli outcomes – Fast and Slow

November 1, 2012 |

I am working on a project that requires the generation of Bernoulli outcomes. Typically, I would go about this using the built in sample() function like so: This works great and is fast, even for large n. Problem is, I want to generate each sample with its own unique probability. ... [Read more...]

### How do I Create the Identity Matrix in R?

June 27, 2012 |

I googled for this once upon a time and nothing came up. Hopefully this saves someone ten minutes of digging about in the documentation. You make identity matrices with the keyword diag, and the number of dimensions in parentheses. __ diag(3) [,...

### An unabashedly narcissistic data analysis of my own tweets. The…

April 2, 2012 |

pie( table( whence.i.tweet )) qplot( whence ) + coord_polar() pie( log( table( whence )))+RColorBrewer ggplot (see below) plot( density( tweets.len )) qplot(... stat="density") + geom_density qplot(...stat="bin") + geom_text(...) tweeple tweep... [Read more...]

### CPU and GPU trends over time

January 25, 2011 |

GPUs seem to be all the rage these days. At the last Bayesian Valencia meeting, Chris Holmes gave a nice talk on how GPUs could be leveraged for statistical computing. Recently Christian Robert arXived a paper with parallel computing firmly in mind. In two weeks time I’m giving an ...

### Random variable generation (Pt 3 of 3)

January 12, 2011 |

Ratio-of-uniforms This post is based on chapter 1.4.3 of Advanced Markov Chain Monte Carlo.  Previous posts on this book can be found via the  AMCMC tag. The ratio-of-uniforms was initially developed by Kinderman and Monahan (1977) and can be used for generating random numbers from many standard distributions. Essentially we transform the ... [Read more...]

### Installing rJava on Ubuntu

October 20, 2010 |

I had some troubles installing rJava on Ubuntu. The easiest solution I found was installing from the command line using: Then it worked without any problems. [Read more...]

### Transitions and transversions in R

January 5, 2010 |

A couple of months ago I wrote the following R function to calculate the number of transitions and transversions between DNA sequences in an alignment. The function is fairly slow (an alignment of ~100 sequences, 800 bp in length takes around 30 second...