From: cfy30 on
Hi,

I am considering Corr(sig, sig) where sig = cos(omega*t). I use the first
principle to calculate the correlation, r =
sum(sig(1:n).*sig(1:n))/((n-1)*std(sig)*std(sig)), in Matlab syntax. I
expect to see a correlation factor of exactly equal to 1. I am seeing the
second harmonic cos(2*omega*t) shows up on the plot. I do understand it is
because cos(omega*t) x cos(omega*t) = 1/2 x (1 + cos(2*omega*t)). Is there
an effective way to get rid of the second harmonic component?


Thanks,
cfy30
From: glen herrmannsfeldt on
cfy30 <cfy30(a)n_o_s_p_a_m.yahoo.com> wrote:

> I am considering Corr(sig, sig) where sig = cos(omega*t). I use the first
> principle to calculate the correlation, r =
> sum(sig(1:n).*sig(1:n))/((n-1)*std(sig)*std(sig)), in Matlab syntax. I

Why the (n-1)

> expect to see a correlation factor of exactly equal to 1. I am seeing the
> second harmonic cos(2*omega*t) shows up on the plot. I do understand it is
> because cos(omega*t) x cos(omega*t) = 1/2 x (1 + cos(2*omega*t)). Is there
> an effective way to get rid of the second harmonic component?

The result is one value. How do you generate a plot from one value?

-- glen
From: Clay on
On May 17, 1:29 am, "cfy30" <cfy30(a)n_o_s_p_a_m.yahoo.com> wrote:
> Hi,
>
> I am considering Corr(sig, sig) where sig = cos(omega*t). I use the first
> principle to calculate the correlation,  r =
> sum(sig(1:n).*sig(1:n))/((n-1)*std(sig)*std(sig)), in Matlab syntax. I
> expect to see a correlation factor of exactly equal to 1. I am seeing the
> second harmonic cos(2*omega*t) shows up on the plot. I do understand it is
> because cos(omega*t) x cos(omega*t) = 1/2 x (1 + cos(2*omega*t)). Is there
> an effective way to get rid of the second harmonic component?
>
> Thanks,
> cfy30

Yes, you integrate over an integral number of periods. Then only the
constant term survives.
From: cfy30 on
Why (n-1)? I found the formula from Wiki,
http://en.wikipedia.org/wiki/Correlation_and_dependence. It should be n?

I want to see how the correlation coefficient changes, if any, with
increasing number of samples. Hence, I have an array r(2), r(3)....r(n)
where n is the number of samples considered.


cfy30


>cfy30 <cfy30(a)n_o_s_p_a_m.yahoo.com> wrote:
>
>> I am considering Corr(sig, sig) where sig = cos(omega*t). I use the
first
>> principle to calculate the correlation, r =
>> sum(sig(1:n).*sig(1:n))/((n-1)*std(sig)*std(sig)), in Matlab syntax. I
>
>Why the (n-1)
>
>> expect to see a correlation factor of exactly equal to 1. I am seeing
the
>> second harmonic cos(2*omega*t) shows up on the plot. I do understand it
is
>> because cos(omega*t) x cos(omega*t) = 1/2 x (1 + cos(2*omega*t)). Is
there
>> an effective way to get rid of the second harmonic component?
>
>The result is one value. How do you generate a plot from one value?
>
>-- glen
>