Skip to content
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

What is coupling coefficients? #61

Closed
YutoMinami opened this issue Jul 19, 2019 · 8 comments
Closed

What is coupling coefficients? #61

YutoMinami opened this issue Jul 19, 2019 · 8 comments

Comments

@YutoMinami
Copy link

What does the function "compute_coupling_coefficients" actually compute in astro-ph/0307515 and/or arXiv/1609.09730?
I have this question because the covariance and sample variance with 100 samples are different.

For the sample variance, I prepared 100 Gaussian fluctuated maps and calculated pseudo-C_\ell with two different maps, e.g. mapN x mapN+1, using NaMaster.

For the covariance with NaMaster, I followed the example in https://namaster.readthedocs.io/en/latest/sample_covariance.html.
The difference is that I prepared two fields,
f0_1,f2_1, f0_2, f2_2, because I wanted to calculate correlation between two different maps.
I modified "cw.compute_coupling_coefficients(f0, f0, f0, f0)" to "cw.compute_coupling_coefficients(f0_1 f0_2, f0_1, f0_2)".
And, "w22.compute_coupling_matrix(f2, f2, b)" to "w22.compute_coupling_matrix(f2_1, f2_2, b)".
These show difference from sample variance.

However, when I revert the calculation of coupling coefficients like "cw.compute_coupling_coefficients(f0_1 f0_2, f0_1, f0_2)" to "cw.compute_coupling_coefficients(f0, f0, f0, f0)", the covariance agreed to sample variance.

@damonge
Copy link
Collaborator

damonge commented Jul 19, 2019

Hi @YutoMinami

I'm slightly confused by the notation you're using. Let's see if this clarifies things:
Let's say you want to compute the covariance between power spectrum cl_A1A2 and power spectrum cl_B1B2. Say that power spectrum cl_A1A2 is the cross-correlation between two fields (fA1,fA2) and cl_B1B2 is the cross-correlation between (fB1,fB2). Then, you should use:

wA=nmt.NmtWorkspace()
wA=nmt.compute_coupling_matrix(fA1,fA2,b)
wB=nmt.NmtWorkspace()
wB=nmt.compute_coupling_matrix(fB1,fB2,b)
cwAB=nmt.NmtCovarianceWorkspace()
cwAB.compute_coupling_coefficients(fA1,fA2,fB1,fB2)

covariance = nmt.covariance_gaussian_covariance(cwAB, spin_A1, spin_A2, spin_B1, spin_B2,
                                                cl_A1B1, cl_A1B2, cl_A2B1, cl_A2B2, wA, wB)

Does this make sense?

@YutoMinami
Copy link
Author

YutoMinami commented Jul 19, 2019

Hi @damonge

With such expression, I'd like to compute the covariance between power spectrum cl_A1A2 cl_A1A2.

fA1_0, fA1_2 = nmt.NmtField(mask, [inmap1[0] ],  nmt.nmtField(mask, inmap1[1:]) )
fA2_0, fA2_2 = nmt.NmtField(mask, [inmap2[0]],  nmt.nmtField(mask, inmap2[1:]) )
wA=nmt.NmtWorkspace()
wA=nmt.compute_coupling_matrix(fA1_2,fA2_2,b)
cw = nmt.NmtCovarianceWorkspace()
#cw.compute_coupling_coefficients(fA1_0,fA2_0,fA1_0,fA2_0) # This results in wrong covariance
cw.compute_coupling_coefficients(fA1_0,fA1_0,fA1_0,fA1_0) # This works well
covariance = nmt.covariance_gaussian_covariance(cw, 2,2,2,2,
                                                cl_A1_2A2_2, cl_A1_2A2_2, cl_A1_2A2_2, cl_A1_2A2_2, wA, wA)

@damonge
Copy link
Collaborator

damonge commented Jul 19, 2019

Hmmmh, that's surprising.
The call to compute_coupling_coefficients should only depend on the masks of the different fields being passed. Since all of your fields have the same mask, this is very strange. Am I interpreting this correctly?

Also, note that if you just want power spectra and covariances for two spin-2 fields, you don't really need to generate any spin-0 fields at all (e.g. you could just pass fA1_2 instead of fA1_0 to compute_coupling_coefficents).

@YutoMinami
Copy link
Author

YutoMinami commented Jul 21, 2019

The call to compute_coupling_coefficients should only depend on the masks of the different fields being passed. Since all of your fields have the same mask, this is very strange. Am I interpreting this correctly?

Yes. I checked again whether the same mask is passed to the different field and it is. Therefore I wondered what coefficients are intended to be calculated in the function.

Also, note that if you just want power spectra and covariances for two spin-2 fields, you don't really need to generate any spin-0 fields at all (e.g. you could just pass fA1_2 instead of fA1_0 to compute_coupling_coefficents).

Thanks.

@YutoMinami
Copy link
Author

YutoMinami commented Jul 30, 2019

Hi @damonge

I'm sorry I checked and re-run my program and found there is an incorrect explanation.
Though I said only
#cw.compute_coupling_coefficients(fA1_0,fA2_0,fA1_0,fA2_0) solved the problem,
actually I also changed from
wA=nmt.compute_coupling_matrix(fA1_2,fA2_2,b)
to wA=nmt.compute_coupling_matrix(fA1_2,fA1_2,b) when I got correct covariance matrix.

This means even for the calculation of variance of cross correlation, the same field is needed as an input.

I reproduced the small variance problem as the following:
I created one CMB sky map with some beam smoothing and two different noise map.
From them I created two CMB sky maps with different noise map (fA_1 and fA_2).
Then I calculate pseudo cl from fA_1 and fA_2 and use them as an input to gaussian_covariance().
For the workspace wA=nmt.compute_coupling_matrix(fA1_2,fA2_2,b) is used.
Then I compared the variance of 'EB' from NaMaster and sample variance.
It shows that in low ell where CMB is dominant and CMB is auto correlated, NaMaster variance agrees to sample variance and in high ell where noise is dominant and noise is cross correlated, NaMaster variance becomes too small compared to sample variance as if there is no noise.

So, my question should be "How can I calculate correct variance from different realization?"

@damonge
Copy link
Collaborator

damonge commented Oct 23, 2019

Hi @YutoMinami
I'm very sorry it's taken me so long to respond. The covariance for the EB power spectrum is very inaccurate in the approximation used by namaster (we show this here: https://arxiv.org/abs/1906.11765), so I'm not completely surprised that this doesn't work well. I this case I think the best way forward is actually using simulations.

I'm still suprised that the resulting covariance depends on the fields you pass to compute_coupling_coefficients if all of them have the same mask... Is that still the case?

@damonge
Copy link
Collaborator

damonge commented Dec 18, 2019

I'll close this for now, but feel free to reopen

@damonge damonge closed this as completed Dec 18, 2019
@YutoMinami
Copy link
Author

Hi @damonge
As I explained in
#61 (comment) ,
I changed both compute_coupling_matrix and compute_coupling_coefficients.
Therefore, I think compute_coupling_coefficients itself doesn't make change.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants