1
votes

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?

1
N is a vector of samples of a Gaussian process. g1 is 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 samples N with unit mean? In that case, just use N = 1 + rand(1000,1); - Luis Mendo
Is it correct if I use the Gaussian function instead of randn function or should I try something else? - user6210457
Sorry, I meant randn, not rand, in my previous comment. If you try N = 1 + randn(1000,1); and check mean(N), var(N) you will see they are very close to 1 - Luis Mendo

1 Answers

1
votes

If you take the vector from randn() and then add one it will have the same standard deviation as before but now it'll also have a mean of 1.

v=randn(1000,1)+1