Hello need help with this
%% SDSU Machine Learning Course (CompE510/EE600/CompE596)
%% Programming Assignment: Probability
%
%
% Instructions
% ————
%
% This file contains code that helps you get started on the
% probability assignment.
%
% For this part of the exercise, you will need to change some
% parts of the code below for various experiments.
%
% Initialization
% clear ; close all; clc
rng(“default”);
%% ================ Part 1: Toss a coin ===================
% Instructions: Define a random variable called “coin” which is a string, takes value
% “head” or “tail” with the probability of taking each
% value being 0.5. E.g.: from [0, 0.5], it is “tail”; from [0.5, 1]
% it is “head”.
% This means, “coin” is a string that equals to
% “head” or “tail” according to the probability.
% Then, complete the following steps.
% Step 1: toss a coin once, and show the value of the
% coin
% Step 2: toss a coin for 10 times, count the
% number of heads. Store the number of
% heads in variable “c” and print its value
% ============================================================
fprintf(‘===== Part 1: Toss a coin ===== n’);
% ====================== YOUR CODE HERE ======================
% Step 1: toss a coin, and show the value of the coin
fprintf(‘Toss a coin …n’);
fprintf(‘The value of the coin: n %sn’, coin);
% Step 2: toss a coin for 10 times and count the number of heads
% Store the number of heads in variable “c” and print its value
fprintf(‘Toss a coin for 10 times …n’);
fprintf(‘The number of heads: n %dn’, c);
% ============================================================
fprintf(‘Program paused. Press enter to continue.n’);
pause;
%% ================ Part 2: Roll a die ================
% Instructions: Define a random variable that represents the die,
% i.e., it can take six possible values, 1 – 6, with
% the probability of taking each value being 1/6.
% Use the function “ceil” and “rand” in this section for
% random generation.
% Then, complete the following steps.
% Step 1: roll a die once
% Step 2: roll a die for 10 times and make a histogram
% showing the distribution (Hint: can use
% function “hist()” to plot the histogram)
% Step 3: roll a die for 10000 times, make a histogram,
% and then plot an empirical cdf (Hint: can use
% function “stairs()” to plot the cdf)
% ============================================================
fprintf(‘===== Part 2: Roll a die ===== n’);
% ====================== YOUR CODE HERE ======================
% Step 1: roll a die once
fprintf(‘Roll a die …n’);
fprintf(‘The value of the die: n %dn’, die);
% Step 2: roll a die 10 times and make a histogram
fprintf(‘Roll a die 10 times …n’);
fprintf(‘Showing the histogram of the die…n’);
% Step 3: roll a die 10000 times, make a histogram, and plot the cdf
fprintf(‘Roll a die 10000 times …n’);
fprintf(‘Showing the empiral cdf of the die…n’);
% ============================================================
fprintf(‘Program paused. Press enter to continue.n’);
% pause;
%% ================ Part 3: Plot a normal distribution ================
% Instructions: Generate 10000 random samples from the normal distribution
% with mean = 1 and variance = 4 (Hint: use function “randn()”).
% Define the variable name as “ND”, e.g.: ND = ….
% Define ND as a vector size 1*10000, but be careful fitdist() takes
% input as column vector, e.g.: 10000*1.
% Then complete the following:
% Step 1: Make a histogram to show the distribution (Hint: use function “hist()”).
% Step 2: Fit a probability density function (normal distribution)
% to the data and plot this function (Hint: use function “fitdist()” and “plot()”)
% ============================================================
fprintf(‘===== Part 3: Plot a normal distribution ===== n’);
% ====================== YOUR CODE HERE ======================
