I want to generate a Gaussian Random Process with Unit Mean(mean=1) in MATLAB. I tried to do randn function but I later learned that it can be only used when mean is 0 so I tried to write the process by hand. I wanted to write the Gaussian function with mean = 1 and var = 1. I tried this code:
N = rand(1000,1);
g1 = (1/(sqrt(2*pi)))*exp(-((N-1).^2)/2);
plot(g1)
m = mean(g1)
v = var(g1)
However, when I check the mean and variance values I get m=0.3406 and v=0.0024. Can you help?
Nis a vector of samples of a Gaussian process.g1is the (first-order) density function. I think you are mistaking those two things. Besides, I don't see why you apply the density function to the samples. Do you simply want to generate the samplesNwith unit mean? In that case, just useN = 1 + rand(1000,1);- Luis Mendorandn, notrand, in my previous comment. If you tryN = 1 + randn(1000,1);and checkmean(N), var(N)you will see they are very close to1- Luis Mendo