-1

I have two spectra which have (wavelength, flux, error) columns. Two spectra are similar to each other except that one has a small shift in wavelength as compared to the other. I have measured the shift by cross-correlating the two spectra. Now, my goal is to measure the chi-square between the two spectra before and after applying the measured shift to one of the spectra. For Chi-sq estimation, I am taking my second spectra as the model. Computing the chi-square is easy. But, how can I estimate the p-values associated with these chi-squares in python?

vivek m
  • 3
  • 2
  • Please share the code you are having problems with. Is the p-values produced by that code faulty? Or are you asking us to write the code for you? – pastaleg Mar 13 '18 at 00:47

1 Answers1

0

Check out scipy.stats.chisquare

>>> from scipy.stats import chisquare
>>> chisquare([16, 18, 16, 14, 12, 12],f_exp=[16, 16, 16, 16, 16, 8])
Power_divergenceResult(statistic=3.5, pvalue=0.62338762774958223)

The first input is the observed frequencies and the second input is the expected frequencies.

The second output is the p-value.

Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31