Stats project for a random variable

Hello. I want to create script that does the following:
1) Simulate 20 repetitions of obtaining a value for X , that is, roll until a 1 is rolled, record the result and repeat this 20 times.. For example, if we roll 6,2,4,4,1 then X = 5 (we count the final roll). Display the 20 'X' values.
2) Calculate and display the mean, variance and standard deviation for the 20 'X' values.

2 件のコメント

James Tursa
James Tursa 2020 年 12 月 10 日
What have you done so far? What specific problems are you having with your code?

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 12 月 11 日
編集済み: Walter Roberson 2020 年 12 月 12 日

1 投票

Rolling turns out to be difficult to model, and normally objects would slip instead of rolling. However fortunately someone has written an S function in C to model rolling: see https://www.mathworks.com/matlabcentral/fileexchange/49374-rolling-ball-on-plane

3 件のコメント

Walter Roberson
Walter Roberson 2020 年 12 月 11 日
編集済み: Walter Roberson 2020 年 12 月 12 日
If you choose to use a CAD program to design the 3d "1" to roll then you might want to use Simscape Multibody Link to import the design file. See https://www.mathworks.com/help/physmod/smlink/ug/installing-and-linking-simmechanics-link-software.html
John D'Errico
John D'Errico 2020 年 12 月 11 日
A splendid answer. Probably written while drinking some Rolling Rock - a beer that I doubt is even sold anymore.
Walter Roberson
Walter Roberson 2020 年 12 月 12 日
Rolling Rock is still sold, but the sites I find say it has declined considerably in quality.

サインインしてコメントする。

Image Analyst
Image Analyst 2020 年 12 月 12 日
編集済み: Image Analyst 2020 年 12 月 12 日

1 投票

Is this a homework problem on Monte Carlo simulation?
I've uploaded plenty of Monte Carlo Demos, attaching some of them again here.
Just search for Monte Carlo or click some of the links on the right.
In the meantime, try getting all 20 rolls. This is a very easy problem, even for beginners. Here's a start:
% Create list of 20 experiments where we roll the die up to 500 times. 500 is enough that we should definitely see a 1 by 500 rolls.
rolls = randi(6, 20, 500);
lookForValue = 1; % Whatever number you want.
for r = 1 : size(rolls, 1)
thisRoll = ... % Get row from rolls matrix.
firstOccurrence(r) = find(........
end
plot(...............

カテゴリ

ヘルプ センター および File ExchangeThermodynamics & Statistical Physics についてさらに検索

質問済み:

2020 年 12 月 10 日

編集済み:

2020 年 12 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by