The simulation that your code performs IS unfair. You have:
-
x = 1:4 and
prob = c(1/2, 1/6, 1/6, 1/6)
The reason why it is unfair is because all outcomes do not have the same probability:
- the outcome
1 has a 50% (or 1/2) chance of landing each time you roll
- the outcomes
2, 3 and 4 all have a 16.66% (or 1/6) percent chance of landing at each roll
Because all outcomes do not have the same probability, we say that the die is unfair. But actually, you have to remember that a die has 6 sides and not 4. So, the true way of rolling an unfair die would be something like:
sample(x = 1:6, size = 20, replace = TRUE, prob = c(0.2, 0.1, 0.1, 0.3, 0.05, 0.25))
So now, we have 6 sides and all sides have different probabilities of landing.
What you need to remember is that all the probabilities' sum must equal to 1.