Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Convert frequency offset to freqcd form #11

Closed
franciumxzf opened this issue Feb 17, 2023 · 2 comments
Closed

Convert frequency offset to freqcd form #11

franciumxzf opened this issue Feb 17, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@franciumxzf
Copy link
Owner

Method 1: calculate directly from original frequency offset by running pfind(alice, bob) and perform the calculation $\frac{1}{1 + \Delta f'} - 1$ or $-\frac{\Delta f'}{1 + \Delta f'}$
Method 2: obtain the result from pfind(bob, alice) and convert the time offset result accordingly
We need to quantify which method has less error.

@franciumxzf
Copy link
Owner Author

franciumxzf commented Feb 20, 2023

Using dataset27 as an example, compare the results from method 1 and method 2:

print((1/(1+bob_freq)-1)) # 1.408126167778967e-05
print((-bob_freq)/(1 + bob_freq)) # 1.4081261677757226e-05
print(alice_freq) # 1.4081094847240294e-05

Notice that results from two expressions in method 1 are quite near, but much different from method 2. This is because the frequency convergency test in our pfind doesn't go to exact 1 but a float number very near to 1. In this dataset:

print((1 + alice_freq) * (1 + bob_freq)) # 0.9999999998331718

If we correct for this in method 1, compare the results:

print((0.9999999998331718/(1+bob_freq)-1)) # 1.4081094847240294e-05
print((0.9999999998331718-1-bob_freq)/(1 + bob_freq)) # 1.4081094847190168e-05
print(alice_freq) # 1.4081094847240294e-05

Now the first expression in method 1 gives the same value as method 2, while the second method lost some accuracy (but very small).

In summary, the major accuracy loss is from the near-1 result in the frequency convergency test. The loss from the calculation (multiplication /division of float number) is much less compare with it.

@franciumxzf
Copy link
Owner Author

To illustrate more on the comparasion of accuracy loss between the two expressions in method 1, we can perform the following calculation:

import numpy as np

for bob_freq in np.geomspace(1e-5, 1e-10, 6):
    print((1/(1+bob_freq)-1))
    print((-bob_freq)/(1 + bob_freq))
    print()

# -9.999900001056439e-06
# -9.99990000099999e-06

# -9.99998999939855e-07
# -9.99999000001e-07

# -9.99999900663795e-08
# -9.999999000000099e-08

# -9.999999828202988e-09
# -9.999999900000002e-09

# -1.000000082740371e-09
# -9.99999999e-10

# -1.000000082740371e-10
# -9.999999999e-11

Up to around 1e-14, we still hold the accuracy. In this way, we can say that the calculation does not remove a lot of accuracy.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant