Turning a probability vector into a state

The problem I faced was in programming a Markov chain application, I wanted to turn a probability vector into an actual state of affairs. Here is what I came up with:



This seems to do the job, but is there an easier way?

UPDATE: As soon as I looked at this again, I realized I did not need to create a map or do two loops:


Comments

  1. Ah, I already see I can do this in one loop: new code tonight!

    ReplyDelete

Post a Comment

Popular posts from this blog

Libertarians, My Libertarians!

"Pre-Galilean" Foolishness