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 ExchangeRF 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