Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB! Write a MATLAB function that simulates a single roll of a n-sided die. The inputsand outputs of the function are: Inputs: The probabilities for

MATLAB!

Write a MATLAB function that simulates a single roll of a n-sided die.

The inputsand outputs of the function are:

Inputs:

The probabilities for each side, given as a vector p = [p1,p2...pn]

Outputs:

The number onthe face of the die after a single roll, i.e.onenumber fromthe setof integers

{1, 2 ,....n}

Note: The sum p1+p2+.....pn must be equal to 1.0, otherwise the probability values are incorrect.

Savethe function as: nsided_die(p)

Test the functionwitha 5-sided die,where theprobabilitiesaregiven by the vector p=[0.10, 0.25, 0.30, 0.15, 0.20]

To test the function, roll the die for N=10,000times and plot the outcome as a stem plot.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago