0
$\begingroup$
signal = randn(100,1);
noise = randn(100,6);
net_signal = signal+noise(:,1);
w = regress(net_signal,[noise(:,1) ones(100,1)]); 
denoise_signal  = net_signal - noise*w;

Hi, I am trying to understand MATLAB function 'regress'. I generated a signal and a noise. I added one of the noise component to this signal. My question is "why is the denoise_signal not equal to actual signal even after regression?"

Please let me know if I am missing something.Thanks

$\endgroup$
  • 1
    $\begingroup$ Since this is a purely programming question related to a MATLAB function, you will have better luck at www.stackoverflow.com $\endgroup$ – ilanman Oct 7 '16 at 15:59
  • $\begingroup$ The answers address the statistical ideas / misunderstandings behind this question. IMO, this should be on topic here. $\endgroup$ – gung - Reinstate Monica Oct 7 '16 at 16:50
2
$\begingroup$

If I understand your question correctly, you are trying to filter out the noise from the net_signal. Let me try to explain to you why this is not what you are doing in your code.

First of all, a regression is not a tool to denoise something, but a tool to describe/estimate (linear) relationships between data/variables. As your simulated signal does not have any constant parameter attached to some stochastic (random) variable, there is no linear relationship in your data. You have just generated random numbers. This means that you can't find a relationship between the signal and the variable.

Here is an example of data you could simulate where you can find a linear relationship (via a regression) between your signal and some variables:

signal = 0.5 X randomvariable + 0.7 X randomvariable2 + randomnoiseterm

Doing a regression on this on a large enough sample would yield coefficients of approximately 0.5 and 0.7. These coefficients will be returned in the vector you call w.

You are kind of right in your thinking though. With a large enough sample you can via a regression, as stated, estimate the linear relationships in your data (in the above case 0.5 and 0.7). Thus, these coefficients can be seen as the denoised relationship between your signal and the random variables.

It's important to know that a regression will not generate these "correct" estimates in all cases. Certain assumptions/requirements must be met before you can be sure that the estimated coefficients correctly describes the true underlying relationship. I would advice you to read up on linear regression and the assumptions behind.

$\endgroup$
  • 2
    $\begingroup$ Welcome to the site, @mfvas. I think this is an answer, but it comes across almost as a set of questions requesting clarification from the OP. Be aware that CV is a pure Q&A site, not a discussion forum. To the extent possible, we want answers to be pure answers. In light of that, you might consider editing this to make it more explicitly an answer. Since you're new here, you might also want to take our tour, which has information for new users. $\endgroup$ – gung - Reinstate Monica Oct 7 '16 at 16:28
0
$\begingroup$

why do you think a regression will perfectly denoise the signal?

with a regression you are trying to get a "best" linear fit of the data. this does not mean at all that you will get a perfect fit.

increase the sample size and see what happens.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.