0% found this document useful (0 votes)
15 views14 pages

PROB ASS (1)

The document discusses the analysis of various random processes to determine their stationarity and time-dependence using simulations in MATLAB. It covers processes defined by equations such as X(t) = At, X(t) = cos(wt + θ), and X(t) = Acos(wt + θ), concluding that the first and last processes are not stationary while the second is time-dependent. Additionally, it includes a simulation of a Poisson process to model the number of messages received on a mobile phone per day.

Uploaded by

Wami Mahammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views14 pages

PROB ASS (1)

The document discusses the analysis of various random processes to determine their stationarity and time-dependence using simulations in MATLAB. It covers processes defined by equations such as X(t) = At, X(t) = cos(wt + θ), and X(t) = Acos(wt + θ), concluding that the first and last processes are not stationary while the second is time-dependent. Additionally, it includes a simulation of a Poisson process to model the number of messages received on a mobile phone per day.

Uploaded by

Wami Mahammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

1.

A random process is given as X (t) =At, where A is uniformly


distributed random variable on (-2, 3). Check if the given RP is WSS
RP or not by using any language (MATLAB, JAVA….) with clear
simulation result?

A random process X(t) is Wide-Sense Stationary (WSS) if:

1. Mean is constant: E[X(t)] does not depend on t.

2. Autocorrelation is a function of ∣t1−t2∣ only: Rxx(t1, t2) = E[X(t1)


X(t2)] depends only on the time difference.

For X(t) = A⋅t, we need to check:

 E[X(t)] = E[A]⋅t (Does this depend on time?)

 Rxx(t1,t2)=E[A⋅t1⋅A⋅t2]

Explanation:

1. Set Parameters: Define the limits for the uniform distribution of AA,
the number of samples T, and the time vector t that ranges from 0 to
10.

2. Simulate random variable A: Generate T random values from a


uniform distribution between A_{min} and A_{max}.

3. Calculate X(t)=A⋅t: Compute the matrix Xt, where each element in


the matrix is the result of multiplying a corresponding value of A by the
time vector t.

4. Calculate the mean of X(t): Find the mean value of each column in
Xt (i.e., the mean across all realizations for each time point).

5. Plot Mean of X(t): Create a plot of meanX against t, with proper titles
and labels.

6. Calculate Autocorrelatione: Compute the correlation of Xt, which


measures how values of X(t) at different times relate to each other.

7. Plot Autocorrelation: Create a heatmap of the autocorrelation


matrix, using t as both axes, with a color bar to represent the
covariance values.

MATLAB Code:
% Parameters

A_min = -2; A_max = 3; % Uniform distribution for A

T = 1000; % Number of samples

t = linspace(0, 10, 100); % Time vector

% Calculate random variable A

A = (A_max - A_min) * rand(1, T) + A_min;

% Calculate X(t) = A * t

Xt = A' * t; % Create a matrix with each row being A*t

% Calculate mean of X(t)

meanX = mean(Xt, 1);

% Plot Mean of X(t)

figure;

plot(t, meanX);

title('Mean of X(t) over time');

xlabel('Time t');

ylabel('Mean of X(t)');

% Autocorrelation matrix of X(t)

autocorr = corr(Xt');

figure;

imagesc(t, t, autocorr);

colorbar;
title('Autocorrelation of X(t)');

xlabel('Time t_1');

ylabel('Time t_2');

SIMULATION

Therefore

 The mean of X(t) should vary linearly with t, as E[X(t)] = E[A] ⋅t, which
is not constant.

show it does not only depend on the time difference ∣t1−t2∣.


 The autocorrelation depends on both t1 and t2, but we compute it to

Since the mean is time-dependent, this process is not WSS.

2. Given a random process X(t)=cos(wt+θ) is uniformly distributed


in the interval(−π/2,π/2), then check this RP if it is time dependent by
using any language with clear simulation?
A random process is time-dependent if its statistical properties (such as
mean,and autocorrelation) change over time.

For a uniform distribution over (a, b), the mean and autocorrelation are fixed.
However, checking if a process is time-dependent requires ensuring that
these properties do not change with time.

Explanation:

1. Set Parameters:

o Set the frequency w as 2π (a constant).

o Define T, the number of samples, and generate a time vector t


ranging from 0 to 10 with 100 points.

2. Generate Random θ:

o Generate T random samples from a uniform distribution in the


interval (−π/2,π/2).

3. Calculate X(t)=cos(wt+θ)

o For each value in t, calculate X(t) using the formula cos(wt + θ) ,


where θ is an array of random values.

4. Plot X(t):

o Create a plot with t on the x-axis and the computed X(t) on the y-
axis. Label the plot and axes accordingly.

5. Compute Mean and autocorrelation:

o Compute the mean of X(t) across the samples (along rows for
each time value).

o Compute the autocorrelation of X(t) across the samples.

6. Plot Mean and autocorrelation:

o Create a subplot with two graphs:

 One graph showing the mean of X(t) over time.

 Another graph showing the variance of X(t) over time.

o Add appropriate titles and labels for both plots.

MATLAB Code:
% Parameters

omega = 1; % Constant frequency

num_samples = 1000; % Number of samples

num_time_points = 100; % Number of time points

t = linspace(0, 10, num_time_points); % Time vector

% Generate uniformly distributed random phase theta in the


interval (-pi/2, pi/2)

theta_samples = unifrnd(-pi/2, pi/2, [num_samples, 1]);

% Calculate the random process X(t)

X_t = zeros(num_samples, num_time_points);

for i = 1:num_samples

X_t(i, :) = cos(omega * t + theta_samples(i));

end

% Mean calculation

mean_X_t = mean(X_t, 1);

% Autocorrelation calculation

R_X = zeros(num_time_points, num_time_points);

for i = 1:num_time_points

for j = 1:num_time_points

R_X(i, j) = mean(X_t(:, i) .* X_t(:, j));

end

end
% Plotting Mean

figure;

subplot(1, 2, 1);

plot(t, mean_X_t, 'b', 'LineWidth', 2);

title('Mean of Random Process X(t)');

xlabel('Time (t)');

ylabel('Mean');

grid on;

% Plotting Autocorrelation

subplot(1, 2, 2);

imagesc(t, t, R_X);

colorbar;

title('Autocorrelation of X(t)');

xlabel('t_1');

ylabel('t_2');

axis xy; % To display the correct orientation of the axes

grid on;

% Adjust layout

sgtitle('Mean and Autocorrelation of X(t) = cos(\omega t + \Theta)');

SIMULATION
Therefore

Since the uniform distribution has not constant mean and


autocorrelation , meaning the random process is time-dependent.

3. We have a random process X(t)=Acos(wt + θ) then prove if this


RP is stationary or not by using any language with clear and neat
simulation result?

For a process X(t), to check if it's stationary, we typically compute the mean,
and autocorrelation over time. If any of these properties change with time,
the process is not stationary.

Explanation:

1. Calculate X(t)=Acos(wt + θ):

o Compute the values of X(t) for each time value t by evaluating


the cosine function with frequency w and phase shift θ.

2. Compute Mean and Variance:

o Mean: Calculate the mean of X(t) for each time point (across all
realizations/samples).

o Variance: Calculate the variance of X(t) for each time point.

3. Plot Mean and Variance:

o Create a figure for plotting.

o Subplot 1: Plot the mean of X(t) against t. Set the title and axis
labels accordingly.

o Subplot 2: Plot the variance of X(t) against t. Set the title and
axis labels accordingly.

MATLAB Code:

% Parameters% Parameters

A = 1; % Amplitude

w_c = 2 * pi; % Frequency (1 Hz)


num_samples = 1000; % Number of samples for B

time_vector = linspace(0, 10, 100); % Time vector from 0 to 10


seconds

% Generate random samples of B

B_samples = unifrnd(-pi/2, pi/2, [num_samples, 1]); % B uniformly


distributed in (-90, 90)

% Initialize X(t)

X_t = zeros(length(time_vector), num_samples);

% Compute X(t) for each sample of B

for i = 1:num_samples

X_t(:, i) = A * cos(w_c * time_vector + B_samples(i));

end

% Calculate mean and variance over the samples

mean_X = mean(X_t, 2);

autocorr = corr(X_t);

% Plot results

figure;

% Mean plot

subplot(2, 1, 1);

plot(time_vector, mean_X);

title('Mean of X(t)');
xlabel('Time (s)');

ylabel('Mean');

grid on;

% Variance plot

subplot(2, 1, 2);

plot(autocorr);

title('AUTOCORRELATION of X(t)');

xlabel('Time (s)');

ylabel('autocorr');

grid on;

SIMULATION
Therefore

 The process X(t) will have a mean and variance that changes with
time, indicating that the process is not stationary.

4. Write a simulation code for messages receiving in to your mobile


phone per a day by giving an example?

This is a typical example of a Poisson process, where the number of


messages received per day follows a Poisson distribution.

Explanation:

1. Set Parameters:

o Set the average number of messages per day λ as 5.

o Set the number of days to simulate for one year (365 days).

2. Generate Poisson-Distributed Messages:

o Use the Poisson distribution to simulate the number of messages


received each day. Each day has a Poisson-distributed number of
messages with a mean of λ=5 .

3. Plot Histogram:

o Create a histogram of the number of messages received per day.

o Display the histogram with 30 bins.

o Set the plot's title and labels for the x and y axes.

4. Display Statistics:

o Compute and print the mean of the number of messages


received per day.

o Compute and print the variance of the number of messages


received per day.

MATLAB Code:

% Parameters

lambda = 50; % Average number of messages per day (Poisson rate)


days = 1; % Number of days to simulate

num_simulations = 1000; % Number of simulations

% Simulate the number of messages received in one day

messages_received = poissrnd(lambda, num_simulations, days);

% Calculate statistics

mean_messages = mean(messages_received);

var_messages = var(messages_received);

% Display results

fprintf('Mean number of messages received in a day: %.2f\n',


mean_messages);

fprintf('Variance of messages received in a day: %.2f\n',


var_messages);

% Plot histogram of the results

figure;

histogram(messages_received, 'Normalization', 'probability');

title('Histogram of Messages Received in One Day');

xlabel('Number of Messages Received');

ylabel('Probability');

grid on;

% Plotting the probability mass function (PMF)

x = 0:max(messages_received);

pmf = poisspdf(x, lambda);

figure;

bar(x, pmf, 'FaceColor', [0.2 0.6 1]);

title('Poisson Probability Mass Function for Messages Received');

xlabel('Number of Messages');

ylabel('Probability');
grid on;

SIMULATION

Therefore

 The number of messages received per day is modeled as a Poisson


process with an average of 5 messages per day. The distribution will
show the count of how many days had 0, 1, 2, etc., messages.

You might also like