I obtained two sets of data from a Monte Carlo simulation of polymer movement.
One is a list of $r^2_{end-to-end}$,
#r-end-squared
58617.14512069625
55606.1082220041
51244.724846185505
65344.140277928964
63392.17236605068
62101.375689808614
58814.8832777033
60040.00627213609
52019.130880313125
56984.44642212785
... ... ... ... ...
and another is a list of $\overrightarrow{r}_{end-to-end}$
# r_end-X r_end-Y r_end-Z
-177.236 100.309 -130.930
-184.354 88.047 -117.760
-172.577 87.168 -117.745
-197.651 103.270 -124.953
-190.053 104.223 -128.100
-187.985 102.387 -127.593
-190.839 91.210 -118.643
-193.851 98.069 -113.333
-177.084 83.960 -116.667
-178.312 92.759 -128.782
... ... ... ... ...
The autocorrelation formula used in the case of $r^2_{end-to-end}$ is as follows:
$$ R(t) = \frac{1}{(n - t) \cdot \sigma^2} \sum_{i=0}^{n-t-1} (X_i - \mu)(X_{i+t} - \mu) $$
where:
- $( n )$ is the number of observations in the dataset,
- $( t )$ is the lag, or the distance between the compared points,
- $( \mu )$ is the mean of the dataset,
- $( \sigma^2 )$ is the variance of the dataset,
- $( X_i )$ and $( X_{i+t} )$ are the data points at indexes $( i )$ and $( i+t )$ respectively.
The autocorrelation value $( R(t) )$ for each lag $( t )$ is calculated by summing the product of the mean-adjusted data points separated by the lag
, and then normalizing the sum by dividing it by the product of the variance and the number of terms in the sum (adjusted for the lag). This calculation is done for each lag from 0 up to the specified number of lags (numLag
), but not exceeding the number of data points (n
). The computed autocorrelation values are then filtered based on the specified thresholds (thresholdMin
and thresholdMax
).
Here's how I adapted the autocorrelation function for the vector dataset:
- Calculate the mean vector $\boldsymbol{\mu}$ by averaging each component of the vectors separately:
$$ \boldsymbol{\mu} = \left( \frac{1}{n}\sum_{i=0}^{n-1} x_i, \frac{1}{n}\sum_{i=0}^{n-1} y_i, \frac{1}{n}\sum_{i=0}^{n-1} z_i \right) $$
- Calculate the autocorrelation function for the vector dataset using the dot product to get a scalar autocorrelation value for each lag $t$:
$$ R(t) = \frac{1}{(n - t) \cdot \sigma^2} \sum_{i=0}^{n-t-1} \left( \mathbf{X}_i - \boldsymbol{\mu} \right) \cdot \left( \mathbf{X}_{i+t} - \boldsymbol{\mu} \right) $$
where $\mathbf{X}_i$ is the vector at index $i$, and $\sigma^2$ is the variance of the magnitude squared of the end-to-end distance vectors. The variance in this case can be calculated as:
$$ \sigma^2 = \frac{1}{n} \sum_{i=0}^{n-1} \left( \| \mathbf{X}_i - \boldsymbol{\mu} \|^2 \right) - \left( \| \boldsymbol{\mu} \|^2 \right) $$
Here, $\| \mathbf{X}_i - \boldsymbol{\mu} \|^2$ is the squared magnitude of the vector difference $\mathbf{X}_i - \boldsymbol{\mu}$.
In the autocorrelation function, the dot product in the summands will give us a scalar value, as the dot product of two vectors is a scalar. This is appropriate since I am interested in the correlation of the scalar magnitudes of the end-to-end vectors.
Now, the correction to the formula is in how $\sigma^2$ is interpreted. In the scalar case, this is simply the variance of the dataset, but for vectors, you're dealing with magnitudes, so you need to find the average of the squared distances from the mean vector, as shown above.
Both formulas were used for an exponential-decay $y = A0 * Exp(-x * 1/t0)$ curve fitting and then drawing a plot for polymer length vs. tau.
The autocorrelation formula used in the case of $r^2_{end-to-end}$ is working fine and giving plots as expected.
However, the formula used in the case of $\overrightarrow{r}_{end-to-end}$ is not giving similar plots.
So, what am I missing in the vector case?