Skip to main content
added 60 characters in body
Source Link

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiplying throughthe leading term by $\cfrac{n}{n}$$\frac{n+k}{n+k}$ and combining everything into a single fraction, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiplying through by $\cfrac{n}{n}$, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiplying the leading term by $\frac{n+k}{n+k}$ and combining everything into a single fraction, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

added 3 characters in body
Source Link

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiplymultiplying through by $\cfrac{n}{n}$, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiply through by $\cfrac{n}{n}$, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiplying through by $\cfrac{n}{n}$, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

added 230 characters in body
Source Link

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \frac{n\hat{x}_n + \sum_{i=n+1}^{n+k}{x_i}}{n+k} \qquad \hat{y}_{n+k} = \frac{n\hat{y}_n + \sum_{i=n+1}^{n+k}{y_i}}{n+k} $$$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \frac{n\hat{a}_n + \sum_{i=n+1}^{n+k}{x_i^2}}{n+k} \qquad \hat{b}_{n+k} = \frac{n\hat{b}_n + \sum_{i=n+1}^{n+k}{y_i^2}}{n+k} \qquad \hat{c}_{n+k} = \frac{n\hat{c}_n + \sum_{i=n+1}^{n+k}{x_iy_i}}{n+k} $$$$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiply through by $\cfrac{n}{n}$, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \frac{n\hat{x}_n + \sum_{i=n+1}^{n+k}{x_i}}{n+k} \qquad \hat{y}_{n+k} = \frac{n\hat{y}_n + \sum_{i=n+1}^{n+k}{y_i}}{n+k} $$ $$ \hat{a}_{n+k} = \frac{n\hat{a}_n + \sum_{i=n+1}^{n+k}{x_i^2}}{n+k} \qquad \hat{b}_{n+k} = \frac{n\hat{b}_n + \sum_{i=n+1}^{n+k}{y_i^2}}{n+k} \qquad \hat{c}_{n+k} = \frac{n\hat{c}_n + \sum_{i=n+1}^{n+k}{x_iy_i}}{n+k} $$

Multihunter's answer is great, and can be modified slightly to mitigate the problem that they point out of the large cumulative squared terms.

Each accumulator variable can be divided by $n$...

$$ \hat{x} = \frac{\sum_{i=1}^{n}x_i}{n}=\bar{x} \qquad \hat{y} = \frac{\sum_{i=1}^{n}y_i}{n}=\bar{y} $$ $$ \hat{a} = \frac{\sum_{i=1}^{n}x_i^2}{n} \qquad \hat{b} = \frac{\sum_{i=1}^{n}y_i^2}{n} \qquad \hat{c} = \frac{\sum_{i=1}^{n}x_iy_i}{n} $$

...which slightly modifies the on-demand correlation function to...

$$ r=\frac{\hat{c}-\hat{x}\hat{y}}{\sqrt{\hat{a}-\hat{x}^2}\sqrt{\hat{b}-\hat{y}^2}} $$

For an additional $k$ new data samples (resulting in a new total of $n+k$ samples), the accumulator variables can be updated as follows...

$$ \hat{x}_{n+k} = \hat{x}_n+\frac{\sum_{i=n+1}^{n+k}{x_i}-k\hat{x}_n}{n+k} \qquad \hat{y}_{n+k} = \hat{y}_n+\frac{\sum_{i=n+1}^{n+k}{y_i}-k\hat{x}_n}{n+k} $$ $$ \hat{a}_{n+k} = \hat{a}_n+\frac{\sum_{i=n+1}^{n+k}{x_i^2}-k\hat{a}_n}{n+k} \qquad \hat{b}_{n+k} = \hat{b}_n+\frac{\sum_{i=n+1}^{n+k}{y_i^2}-k\hat{b}_n}{n+k} \qquad \hat{c}_{n+k} = \hat{c}_n+\frac{\sum_{i=n+1}^{n+k}{x_iy_i}-k\hat{c}_n}{n+k} $$

Those update functions can be simplified somewhat by multiply through by $\cfrac{n}{n}$, but that reintroduces the issue of potentially having to deal with very large intermediate terms.

Source Link
Loading