I am working with the R programming language.
Suppose I have the following set up:
- There are 5 objects : A, B, C, D, E
- The probability for each of these objects to be chosen is : 0.2, 0.3, 0.1, 0.3, 0.1
- You want to pick 5 of these objects with replacement (e.g. ABACD, DDBCA, etc.)
I want to find out (exact solution):
- All combinations that can be made from these 5 objects
- The probability for each of these combinations
Currently, I do not know how to do this - I tried to do this by simulating a "large number of combinations" and hoping I sufficiently saw enough of each combination to infer the correct probability :
library(dplyr)
results <- list()
for (i in 1:100) {
iteration = i
sample_i = sample(c("A", "B", "C", "D", "E"), size =5, replace = T, prob= c( 0.2, 0.3, 0.1, 0.3, 0.1))
my_data_i = data.frame(iteration, sample_i )
results[[i]] <- my_data_i
}
results_df <- data.frame(do.call(rbind.data.frame, results))
But this is looking like a very complicated way of solving this problem. In the end, I would be looking for something like this:
- AAAAA : Prob = 0.03
- AABDE: Prob = 0.06
- DEECB : Prob = 0.07
- etc.
Can someone please show me how to do this?
Thanks!