p1_t=(p1_{t-1}*w1_{t-1})/(\bar{w_{t-1}})

p2_t=(p2_{t-1}*w2_{t-1})/(\bar{w_{t-1}})

p3_t=(p3_{t-1}*w3_{t-1})/(\bar{w_{t-1}})

Where the vector W is equal to a payoff matrix

1 .5 2

2 1 .5

.5 2 1

multiplied by the vector of that period's p's

(i.e. w1_t = p1_t * 1 + p2_t * .5 + p3_t * 2 etc...)

and

\bar{w_t} = w1_t * p1_t + w2_t * p2_t + w3_t * p3_t

I am starting with initial conditions that

p1_0 = 0.1

p2_0 = 0.2

p3_0 = 1 - p1_0 - p2_0

What I have done so far (and I'm sure is completely wrong) is:

Code:

```
function(A){
rdirichlet<-function(n,a){
l<-length(a);
x<-matrix(rgamma(l*n,a),ncol=l,byrow=TRUE);
sm<-x%*%rep(1,l);
x/as.vector(sm);
}
error <- rdirichlet(100, c(1,1,1) )
p1_1<- 0.3
p2_1<- 0.4
p3_1<- 1 - p1_1 - p2_1
w1_1 <- (p1_1 * 1 + p2_1 * 0.5 + p3_1 * 2)
w2_1 <- (p1_1 * 2 + p2_1 * 1 + p3_1 * 0.5)
w3_1 <- (p1_1 * 0.5 + p2_1 * 2 + p3_1 * 1)
wbar_1 <- (p1_1 * w1_1 + p2_1 * w2_1 + p3_1 * w3_1)
for(i in 1:100){
j <- i + 1
p1_1 -> p1_i
p2_1 -> p2_i
p3_1 -> p3_i
w1_1 -> w1_i
w2_1 -> w2_i
w3_1 -> w3_i
wbar_1 -> wbar_i
p1_j <- p1_i * w1_i / wbar_i
p2_j <- p2_i * w2_i / wbar_i
p3_j <- 1 - p1_j - p2_j
}
for(j in 1:100){
p1_j -> p1_j
p2_j -> p2_j
p3_j -> p3_j
fq <- c(p1_j, p2_j, p3_j)
}
cnames <- c("Y", "B", "O")
rnames <- c(0:100)
freq <- matrix(fq, nrow=101, ncol=3, byrow=TRUE, dimnames=list(rnames, cnames) )
return(freq)
}
```

Ignore the dirichlet bit. I am going to use that to create an error term later.

Any help is much appreciated.