Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The MATLAB ‘rand’ function generates random numbers from a uniform distribution

ID: 3803998 • Letter: T

Question

The MATLAB ‘rand’ function generates random numbers from a uniform distribution from 0.0 to 1.0. and the MATLAB function ‘randn’ generates random numbers from a normal Gaussian distribution with a mean of 0.0 and a standard deviation of 1.0.

The MATLAB "rand' function generates random numbers from a uniform distribution from 0.0 to 1.0. and the MATLAB function randn' generates random numbers from a normal Gaussian distribution with a mean of 0.0 and a standard deviation of 1.0. a) In a particular Matlab script, it is desired to implement the random variable "x" which is a random value taken from a Gaussian random distribution with mean 2.0 and variance 0.25. Complete the following Matlab statement assigning an appropriate value to x b) A Matlab script implements a 3 state Markov model. Assume that the parameters "al l, al2, a13, a21, a22, a23, 31, 32, a33" have all been defined in the script initialization and have already been set equal to the corresponding model transition probabilities. The parameter "state" has also been defined to represent the current state of the model (1, 2 or 3). The following segment of Matlab script is intended to determine the next state of the model given the current state and the predefined transition probabilities. Complete all of the indicated blank segments in the script in order to implement the correct state transition logic. if state 1 state-1; else if r State 2 else State 3; end else if state 2 if r state 1 else if r state 2 else state-3; end else if state 3 if r state l else if r state 2: else state-3 end end

Explanation / Answer

We can use normrnd(mu,sigma) function which is predefined in matlab.. cheers! :D
normrnd(mu,sigma) generates random numbers from the normal distribution with mean parameter mu and standard deviation parameter sigma.

In the qeuestion the values given are mean and variance, and we need sd in the function. And we know that sq is square root of variance, so we have to use sqrt(0.25) in place of sd

If you have any confusion please comment below.

So your answer would be
              x = normrnd(2,sqrt(0.25));

2.

r = rand(1); %we generate a randon number
if state == 1
    if r < a11 %r is less than the first probability
        state= 1; %we move to state 1
    elseif r < a11 + a12 %if the r is more than frist probabilty and less than 2nd prob
        state=2; %we move to stage 2
    else
        state=3; % if r is more than first two probability, we move to stage 3
    end
elseif state == 2
    if r < a21
        state= 1;
    elseif r < a21 + a22
        state=2;
    else
        state=3;
    end
elseif state == 3
    if r < a31
        state= 1;
    elseif r < a31 + a32
        state=2;
    else
        state=3;
    end
end

Please go through the comments and let me know if you have any difficulty understanding

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote