marcincuber
marcincuber

Reputation: 3791

matlab least squares random sample generation

I am looking for some help in generating a noisy random data set with 600 samples. Currently I am using following code:

weight = randn(size,1);
noise = randn(size,1);
X = randn(size);
y = (X'*weight) + noise;

Weight is just a vector ∈ R. I need 600 samples that are split into one set of size 500 and another one of size 100. Help Please?
Later I will be computing mean squared error on these sets but this should be a lot easier.

Upvotes: 0

Views: 98

Answers (1)

Mikhail_Sam
Mikhail_Sam

Reputation: 11238

I suggested size = 600 if you need 600 samples.

I don't understand what for do you use randn for three times with multiplication and sum (maybe you want some special distribution) but - You want noise signal, so you get it: you can check it by using autocorr function for y: enter image description here

To divide your sample in two of different size use this:

y1 = y(1:100);
y2 = y(101:600);

Hope, it helps!

Upvotes: 0

Related Questions