Thread View: alive.statistics
2 messages
2 total messages
Started by Pedro Cardoso
Sun, 02 Oct 2005 22:01
[urgent]: random sample with predefined correlation
Author: Pedro Cardoso
Date: Sun, 02 Oct 2005 22:01
Date: Sun, 02 Oct 2005 22:01
17 lines
1544 bytes
1544 bytes
Hello all, I have this problem:
I have a vector x of values and I would like "randomly" produce other
vector y,
such that correlation(x,y) is equal to some predefined value.
example:
x=(1, 2, 1, 2, 3, 4, 5, 1, 8)
y=(?, ?; ?, ?, ?, ?, ?, ?, ?)
correlation(x,y)=0.7
Can anyone help?
best regards,
Pedro.
Re: [urgent]: random sample with predefined correlation
Author: Ray Koopman
Date: Mon, 03 Oct 2005 07:41
Date: Mon, 03 Oct 2005 07:41
23 lines
1883 bytes
1883 bytes
Pedro Cardoso wrote:
> Hello all, I have this problem:
>
> I have a vector x of values and I would like "randomly" produce other
> vector y,
> such that correlation(x,y) is equal to some predefined value.
>
> example:
> x=(1, 2, 1, 2, 3, 4, 5, 1, 8)
> y=(?, ?; ?, ?, ?, ?, ?, ?, ?)
> correlation(x,y)=0.7
>
>
> Can anyone help?
>
> best regards,
> Pedro.
I assume you would like Mathematica code again. This should do it:
y = {0,r,Sqrt[1-r^2]}.First@QRDecomposition[{1.,#,Random[]}&/@x]
where r is the desired correlation[x,y]. Tr@y == 0. && y.y == 1.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads