Generating Random Numbers with known probability and more
Afficher commentaires plus anciens
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 commentaires
KALYAN ACHARJYA
le 30 Nov 2019
For homework or assignment questions, we expect efforts from students. If you are stuck, tell us the specific problem.
wfcsoccer12
le 30 Nov 2019
Star Strider
le 30 Nov 2019
Remember:
‘You extract 10 candies at random.’
Réponses (1)
" 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).
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!