Simulating the selection of a state with given probabilities - MATLAB Cody - MATLAB Central

Problem 2356. Simulating the selection of a state with given probabilities

Difficulty:Rate

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

37.04% Correct | 62.96% Incorrect
Last Solution submitted on Jan 28, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
6

Problem Recent Solvers26

Suggested Problems

More from this Author6

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!