# Blog Archives

## Weekend art in R (Part 2)

June 26, 2010
By

I put together four of the best looking images generated by the code shown here: # More aRt par(bg="white") par(mar=c(0,0,0,0)) plot(c(0,1),c(0,1),col="white",pch=".",xlim=c(0,1),ylim=c(0,1)) iters = 500 for(i in 1:iters) { center = runif(2) size = 1/rbeta(2,1,3)   # Let's create random HTML-style colors color = sample(c(0:9,"A","B","C","D","E","F"),12,replace=T) fill = paste("#", paste(color[1:6],collapse=""),sep="") brdr = paste("#", paste(color[7:12],collapse=""),sep="")   points(center[1], center[2],

## Reaching escape velocity

June 22, 2010
By

Sample once from the Uniform(0,1) distribution. Call the resulting value . Multiply this result by some constant . Repeat the process, this time sampling from Uniform(0, ). What happens when the multiplier is 2? How big does the multiplier have to be to force divergence. Try it and see: iters = 200 locations = rep(0,iters)

## The perfect fake

June 19, 2010
By

Usually when you are doing Monte Carlo testing, you want fake data that’s good, but not too good. You may want a sample taken from the Uniform distribution, but you don’t want your values to be uniformly distributed. In other words, if you were to order your sample values from lowest to highest, you don’t

## Those dice aren’t loaded, they’re just strange

June 18, 2010
By

I must confess to feeling an almost obsessive fascination with intransitive games, dice, and other artifacts. The most famous intransitive game is rock, scissors, paper. Rock beats scissors.  Scissors beats paper. Paper beats rock. Everyone older than 7 seems to know this, but very few people are aware that dice can exhibit this same behavior,

## Repulsive dots pattern, the difference of distance

June 14, 2010
By

What if you wanted to randomly place objects into a field, and the more objects you had, the more they rejected newcomers placed nearby? To find out, I setup a simulation. The code, shown at the end, isn’t all that interesting, and the plots shown below aren’t all that special. I think there is one

## A different way to view probability densities

June 12, 2010
By

The standard, textbook way to represent a density function looks like this: Perhaps you have seen this before? (Plot created in R, all source code from this post is included at the end). Not only will you find this plot in statistics books, you’ll also see it in medical texts, sociology, and even economics books.

## Betting on Pi

May 31, 2010
By

I was reading over at math-blog.com about a concept called numeri ritardatari. This sounds a lot like “retarded numbers” in Italian, but apparently “retarded” here is used in the sense of “late” or “behind” and not in the short bus sense. I barely scanned the page, but I think I got the gist of it:

## Weekend art in R (part 1?)

May 29, 2010
By

As usual click on the image for a full-size version. Code: par(bg="black") par(mar=c(0,0,0,0)) plot(c(0,1),c(0,1),col="white",pch=".",xlim=c(0,1),ylim=c(0,1)) iters = 500 for(i in 1:iters) { center = runif(2) size = rbeta(2,1,50)   # Let's create random HTML-style colors color = sample(c(0:9,"A","B","C","D","E","F"),12,replace=T) fill = paste("#", paste(color[1:6],collapse=""),sep="") brdr = paste("#", paste(color[7:12],collapse=""),sep="")   rect(center[1]-size[1], center[2]-size[2], center[1]+size[1], center[2]+size[2], col=fill, border=brdr, density=NA, lwd=1.5) }

## R: More plotting fun with Poission

May 28, 2010
By

Coded as follows: x = seq(.001,50,.001) par(bg="black") par(mar=c(0,0,0,0)) plot(x,sin(1/x)*rpois(length(x),x),pch=20,col="blue")