Generating Random Numbers with known probability and more
2 views (last 30 days)
Show older comments
Hi,
I am trying to solve this problem but can't figure out how to execute it. I know I need to create a line of code that allows me to pick either 0 or 1 to represent sweet and sour and needs to be simulated 500 times, but there is a predetermined probability for each one to be chosen. Can anyone give me some type of direction? Here is the question.
Suppose you have a box with candies. Note that 60% of the candies are sour, the rest are sweet. You extract 10 candies at random.
- Code in MATLAB a simulation of the candy box and the extraction process.
- Run 500 simulations of a. On each simulation, compute the number of sour candies you obtain.
- Compute the theoretical value of the expected value of sour candies in b. and compare with the one you obtained.
- Use the results of your simulation in b. to compute the variance.
- Compute the theoretical value of the variance and compare with the obtained in d.
3 Comments
Answers (1)
Adam Danz
on 1 Dec 2019
Edited: Adam Danz
on 2 Dec 2019
" I know I need to create a line of code that allows me to pick either 0 or 1 to represent sweet and sour ... but there is a predetermined probability for each one to be chosen. Can anyone give me some type of direction? "
If you have the statistics and machine learning toolbox, start my briefly reading the documentation and exploring the examples on this page (link below).
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!