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

답변 (1개)

Image Analyst
Image Analyst 2021년 3월 17일

0 개 추천

It is because you never call display().

카테고리

도움말 센터File Exchange에서 RF Toolbox에 대해 자세히 알아보기

질문:

2021년 3월 17일

답변:

2021년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by