Recovery from Fourier expansion
Last update on the 29th of October, 2019Here I study recovery quality of a function after fourier expansion and application of noise and filtration. The function imitates 1-D distribution of molecular electron density. Main results are collected in Table 1.
Harmonic set | Resolution | Completeness | F noise | φ noise | Recovery quality |
---|---|---|---|---|---|
0-1 | 30 Å | 100% | 0% | 0% | Bad |
0-13 | 30/13 Å | 100% | 0% | 0% | Medium |
0-26 | 30/26 Å | 100% | 0% | 0% | Good |
0-40 | 30/40 Å | 100% | 0% | 0% | Excellent |
0-1 | 30 Å | 100% | 20% | 20% | Bad |
0-13 | 30/13 Å | 100% | 20% | 20% | Medium |
0-26 | 30/26 Å | 100% | 20% | 20% | Medium |
0-40 | 30/40 Å | 100% | 20% | 20% | Medium |
2-40 | 1.0 Å | 96.55% | 0% | 0% | Good |
2-17,22-40 | 1.7 Å | 94.12% | 0% | 0% | Good |
2-40,50 | 1.0 Å | 96.55% | 0% | 0% | Good |
Function generation
I generated sample electron density function with compile-func.py -g 30,3,3+40,3,4.3+2,3.5,6.5+30,3,7.5
.
The image of the function is presented in Fig. 1.
![](func.png)
Excellent recovery
The Fourier expansion was applied to the function with no noise on amplitudes and phases. Excellent recovery was achieved at the first 40 harmonics of Fourier series (Figs. 2, 3).
![](side_by_side_4_no_noise.png)
![](full_no_noise.gif)
Noise modelling
20% noise was applied on amplitudes and phases while performing Fourier expansion. Recovery of the function from noisy Fourier expansion achieved medium quality at the first 40 harmonics (Figs. 4, 6). Solid peaks are quite distinguishible from noise but not the small peak (Fig. 5).
![](side_by_side_4_noise.png)
![](side_by_side_noise.png)
![](full_noise.gif)
Incomplete set of harmonics
No starter harmonics
Removal of the first two harmonics hasn't almost affected recovery quality: all initial peaks are still distinguishable from the background (Fig. 7).
![](side_by_side_no_start.png)
No middle harmonics
Further removal of some middle harmonics has greatly affected peak recovery (Fig. 8).
![](side_by_side_no_med.png)
Plus distant harmonic
Addition of the 51st harmonic after removal of the first two harmonics hasnt' rescued imbalanced recovery of the function (Fig. 9).
![](side_by_side_plus_end.png)
Resolution criterion
Resolution of the incomplete set of harmonics is defined by the researcher. First, I developed a function that calculates the completeness of the incomplete set of harmonics at the given resolution.
def calc_completeness(observed, full, res, length): """Calculates completeness of set of harmonics. Args: observed (np.ndarray): array with serial numbers of observed harmonics. full (np.ndarray): array with serial numbers of full set of harmonics. res (int, float): resolution at which calculate the completeness. length (int, float): length of segment at which harmonics are defined. Returns: (int, float) completeness of observed set of harmonics at given resolution. """ total = np.sum((length / full) > res) detected = np.sum((length / observed) > res) if total != 0: return detected / total return 0
Completenesses of the three incomplete sets of harmonics are generally desceneding functions of the resolution (Figs. 10-12).
![](completeness_no_start.png)
![](completeness_no_med.png)
![](completeness_plus_end.png)
I propose a criterion of the resolution of the incomplete set of harmonics: the lowest resolution with the greatest completeness. Derieved resolutions for the three incomplete sets of harmonics are shown in the Table 2.
def max_completeness(completeness): """Finds resolution with maximal completeness. Args: completeness (list of tuples): list of 2-item tuples like `(resolution, completeness)`. Returns: (tuple) resolution with maximal completeness and corresponding completeness. """ return max(completeness, key=lambda x: x[1])
Type | Resolution | Completeness |
---|---|---|
No starter | 1.0 Å | 96.55% |
No middle | 1.7 Å | 94.12% |
Plus distant | 1.0 Å | 96.55% |