Question

Perform the following using Matlab For an additive Gaussian noise: a. Generate 4000 samples with mean value of 3 and variance

using matlab

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc
clear
close all

% gaussian / normal distibution

% part a
N = 4000;
varr = 9;
sd = sqrt(varr);
mu = 3;
gauss_samples = sd.*randn(N,1) + mu;

histrogram 1200 1000 800 S 600 400 200 0 -10 -5 0 5 10 15

pdf 0.3 0.25 0.2 X 0.15 0.1 0.05 0 0 500 1000 1500 2000 2500 3000 3500 4000

cdf 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 2 0 500 1000 1500 2000 2500 3000 3500 4000

COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,

IF YOU'RE SATISFIED, GIVE A THUMBS UP

% part b
figure
plot(gauss_samples,'-')
title(['additive guassian noise of mu = ' num2str(mu) ', var = ' num2str(varr)])
xlabel('sample (n)')
ylabel('value (x)')

figure
plot(gauss_samples,':')
title(['additive guassian noise of mu = ' num2str(mu) ', var = ' num2str(varr)])
xlabel('sample (n)')
ylabel('value (x)')

%part c
actual_mean = mean(gauss_samples)
actual_var = var(gauss_samples)
actual_std = sqrt(actual_var)

% part d

%median_value = median(gauss_samples)
sorted_samples = sort(gauss_samples);
if mod(N,2)~=0
median_value = sorted_samples(ceil(N/2))
else
median_value = (sorted_samples(N/2)+sorted_samples((N/2)+1))/2
end

mode_value = mode(gauss_samples)

% part e
figure
h = hist(gauss_samples);
hist(gauss_samples)
title('histrogram')
xlabel('x')
ylabel('frequancy of x')
grid on

%part f
%PDF
pdf = h./(sum(h));
x = linspace(0,N,numel(h));
figure
plot(x,pdf,'linewidth',2)
xlabel('x')
ylabel('p(X=x)')
title('pdf')
grid on

%CDF
cdf = cumsum(pdf)
x = linspace(0,N,numel(h));
figure
plot(x,cdf,'linewidth',2)
xlabel('x')
ylabel('p(X<=x)')
title('cdf')
grid on

Add a comment
Know the answer?
Add Answer to:
Perform the following using Matlab For an additive Gaussian noise: a. Generate 4000 samples with ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT