Monte Carlo simulation dice roll

Define a single function named display that returns nothing and takes two input parameters, an array of counters and the singular counter for the number of doubles rolled. The function displays the estimated probability of rolling each of the potential values from 1 to the maximum number that can be rolled (which can be calculated from the aforementioned input parameters).
Recall, estimated probability is the calculated estimate of the theoretical probability of a scenario. To calculate an estimated probability we take the number of occurrences for a scenario and divide by the number of possible occurrences (the number of simulations).
I am unsure why my for loop is not printing out the statement. I also dont know how to get the probablity.
[numSims, numDice, numSides]=userInput();
x=zeros(1,numDice*numSides);
y=zeros();
function [numSims, numDice, numSides]=userInput()
numSims=input("How many simulations?");
numDice=input("How many dice?");
numSides=input("How many sides on each die?");
end
function display(x,y)
for i=1:length(x)
fprintf('Estimated probablity of rolling a %d/n',i (': %d/n'));
end
end

Respuestas (1)

Image Analyst
Image Analyst el 17 de Mzo. de 2021

0 votos

It is because you never call display().

Categorías

Más información sobre RF Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 17 de Mzo. de 2021

Respondida:

el 17 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by