MATLAB: Problem with noisy gaussian function

functiongaussianMATLABmatlab functionnoisy

Hello everyone ,
I'm student(from France). This is the problem : "Create a noisy gaussian function using the Matlab built-in function rand . You'll first check what rand is doing using help rand. The idea will be to create random-numbers having a mean value zero(i.e positive and negative numbers)."
I did for help rand . It's an array but I didn't understand how can i create this function . If you have clue or some advice . Thanks you very much .

Best Answer

Bellow is an rough attempt of mine:
clearvars; clc; close all;
%%parameters
N=2^16; % rand() outputs
M=2^7; % number of rand that we will use
%%uniformly distributed random numbers
x1=rand(1,N)-0.5;
% probability density function
h1=histogram(x1);
h1.Normalization = 'probability';
title('uniform distribution')
%%combination of M rand() functions
x2=zeros(1,N);
for k=1:M
x2=x2+rand(1,N)-0.5;
end
%probability density function
h2=histogram(x2);
h2.Normalization = 'probability';
h2.FaceColor=[0 .5 0];
title('Normal distribution');
If you run this script, you will receive :