-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better estimation of real-time correlations #218
Comments
I wonder if the default should be windowing. That seemed to have the greatest effect in the results Sam was reporting at the end of last year. Xiaojian the other day was pointing out the symmetrization doesn't work as well as he'd like in some cases. |
Could be. Shall we collect data for the various S(q,w) results for some simple, prototypical model? How about we compare LSWT, small T classical dynamics with/without :symmetrize in current Sunny, and with @Lazersmoke's upcoming windowing scheme? |
Two comments on this. Firstly, is the implementation of this correct? It seems to me like this for loop is only correct up to t/2, since it is reading and writing from samplebuf on every iteration:
Secondly, the effect of this option is exactly the same as using the correlations of the time-reversed trajectory (of each sampled trajectory) as an additional estimator of the true correlations. This is certainly not correct in the general case (see the test_correlation_sampling test case on the asymmetric-rebased branch). There is some reason to suspect that the correlations may be time-symmetric when the system is in equilibrium. So having |
Correctness of statistics from time-reversed trajectories seems contingent on:
I think 1. is a valid assumption for the large majority of use cases (although @Lazersmoke's research is a notable exception). I think I'd be OK with assuming equilibrium by default (with an "opt out" option) if that were to provide advantages in the common case. I think 2. could be more concerning -- if the magnetic ordering breaks chiral symmetry, is it possible that the dynamics is not time-reversal symmetric? Perhaps @hlane33 also has insight. |
To @Lazersmoke's first point, I think they are right that the implementation is wrong. The combination of forward and reverse trajectories is incorrectly weighted after passing the midpoint. If we want to avoid having an allocation or a buffer, that loop can just be run to the midpoint and then the second have can be filled with the time-reversal of the completed first half (or do the setting of mirrored points simultaneously). To @kbarros's point, we did discuss a simple model some time last year, I think in November. I believe our main conclusion, with respect to just eliminating artifacts due to the discontinuity at the periodic extension, was that a simple cosine window was preferable to symmetrization. That said, it looks like the implementation of symmetrization was incorrect, so it would be worth revisiting. |
After playing with the math, I agree now that |
I spent some more time on this, and I think there could be something interesting here. See attached note. After averaging over an arbitrary phase, a factor of |
As can be seen by the sqrt(2), the correlations depend non-linearly on the trajectories. So the symmetrized procedure actually involves a linear combination of the four correlations |
For posterity, here is an extension of the note for calculating the cross correlation between two different real signals A(t) and B(t). It appears that the technique will still work in this more general case, and an overall correction factor of sqrt(2) is still needed. I suspect that Sam's more recent approach (zero padding to mask unphysical correlations and then cosine windowing to dampen statistical noise) will be overall better, but it would be good to get a detailed comparison before selecting a new default. |
In this note, it's shown that, after equilibrium averaging, the quantity However, this is not the same thing as the real part of The upshot is that this note means that we can document the option as providing "time-symmetrized correlations (on equilibrium average)" :) |
We discussed on Slack. The symmetrized_signal2.pdf note seems mathematically correct, but there are caveats in the physical interpretation:
|
process_trajectory=:symmetrize
the default
It turns out to be very important that the window function applied to the time correlations (or the "default" box window) is exactly symmetric. Otherwise you can get imaginary valued or negative intensities. I've implemented this here: The subtlety is that |
Just another data point I found: Their approach involves computing a trajectory on the interval Because of all of those reasons listed above, the As you can see, they don't match. The point is to say that this is subtle; we zero-pad so we won't have this bug, but generally speaking the bugs are difficult to detect. |
This was fixed in #246. |
This greatly reduces artifacts. Is there a reason not to?Repurposing this issue for a discussion of possible improvements to the estimation of dynamical correlations. We currently have
process_trajectory=:symmetrize
, analyzed below, and @Lazersmoke is working on a different approach that avoids "periodic wrapping" of correlations on a finite time trajectory.For the latter, here is a note that builds on @Lazersmoke's ideas:
causal_correlations.pdf
The text was updated successfully, but these errors were encountered: