Problem 2356. Simulating the selection of a state with given probabilities
Lets say we have 3 different states [1,2,3] with the probabilities of occurrences of each state is given as [0.5 0.2 0.3]. Which means 50% state 1 will be selected among others. Generate randomly selected states with the probabilities given
Output array will be consisting of state numbers based on the probabilities given as input.
Example: (Quick tip: The higher simulation sampling sizes the more robust results)
Solution Stats
Problem Comments
-
2 Comments
It's not clear to me what select_state is supposed to return. I would have thought it was one of the state (i.e. one of 1, 2, 3, ...) but it's not what the test suite tests for.
Returning the passed in probability with a very small deviation is enough to pass the test suit. This doesn't seem right.
Guillaume, i changed the problem output to states rather than the probability values. This way looks better i presume. Thanks for the comment. Cheers
Solution Comments
Show commentsProblem Recent Solvers26
Suggested Problems
-
It dseon't mettar waht oedrr the lrettes in a wrod are.
1914 Solvers
-
Return the first and last characters of a character array
10443 Solvers
-
904 Solvers
-
Determine if input is a perfect number
242 Solvers
-
Remove entire row and column in the matrix containing the input values
408 Solvers
More from this Author6
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!