How to simulate a loaded dice in Igor Pro?
Wed, 03/10/2021 - 08:12 am
Hi. I am looking for a way to generate random states with non-equal probabilities. A simple example to illustrate this would be a loaded dice, where outcome of 1 is 2p/3, the probability of obtaining 2, 3, 4 or 5 is p each, and the probability of obtaining 6 is 3p/2. My approach so far has been to pick random numbers from a wave that would have 6x100 points with the first 66 points equal 1, next 100 equal 2, and so on, with the last 137 points equal to 6. This code shows how a loaded coin would work:
However this is computationally very expensive and takes too long to be practical, as I need to generate large sets of data. Also has low resolution, as sometimes the probabilities are at the 7th digit, and making a wave with Nx10^7 only makes things worse.
Is there a function in Igor Pro similar to the one in R that can do this faster/in one shot? This is how that code would look like:
x <- sample(1:6, size = 100, replace = TRUE, prob = myprobs)