Question: 1. Function for a n-sided die . Write a MATLAB function that simulates a single roll of a n-sided die. The inputs and outputs of

1. Function for a n-sided die . Write a MATLAB function that simulates a single roll of a n-sided die. The inputs and outputs of the function are: Inputs: The probabilities for each side, given as a vector p =[P1, P2, -- Pn] Outputs: The number on the face of the die after a single roll, i.e. one number from the set of integers {1,2,..n} Note: The sum p. + P2 + ... PA must be equal to 1.0, otherwise the probability values are incorrect. Save the function as: nsided_die (p) Test the function with a 6-sided die, where the probabilities are given by the vector p =[0.20, 0.05,0.10, 0.25, 0.30, 0.10]. To test the function, roll the die for N=1000 times and plot the outcome as a stem plot. SUBMIT a report that follows the guidelines as described in the syllabus. The section on RESULTS must include The PMF in the form of a stem plot The code must be provided in the appendix
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
