25#include <lal/LALInferenceLikelihood.h>
26#include <lal/LALInferencePrior.h>
27#include <lal/LALInference.h>
28#include <lal/DetResponse.h>
29#include <lal/TimeDelay.h>
30#include <lal/TimeSeries.h>
32#include <lal/Sequence.h>
33#include <lal/FrequencySeries.h>
34#include <lal/TimeFreqFFT.h>
35#include <lal/LALInferenceDistanceMarg.h>
37#include <gsl/gsl_sf_bessel.h>
38#include <gsl/gsl_sf_dawson.h>
39#include <gsl/gsl_sf_erf.h>
40#include <gsl/gsl_complex_math.h>
41#include <lal/LALInferenceTemplate.h>
45#include <lal/distance_integrator.h>
59#define UNUSED __attribute__ ((unused))
105 ----------------------------------------------\n\
106 --- Likelihood Arguments ---------------------\n\
107 ----------------------------------------------\n\
108 (--zeroLogLike) Use flat, null likelihood\n\
109 (--studentTLikelihood) Use the Student-T Likelihood that marginalizes over noise\n\
110 (--correlatedGaussianLikelihood) Use analytic, correlated Gaussian for Likelihood Z=-21.3\n\
111 (--bimodalGaussianLikelihood) Use analytic, bimodal correlated Gaussian for Likelihood Z=-25.9\n\
112 (--rosenbrockLikelihood) Use analytic, Rosenbrock banana for Likelihood\n\
113 (--noiseonly) Using noise-only likelihood\n\
114 (--margphi) Using marginalised phase likelihood\n\
115 (--margtime) Using marginalised time likelihood\n\
116 (--margtimephi) Using marginalised in time and phase likelihood\n\
117 (--margdist) Using marginalisation in distance with d^2 prior (compatible with --margphi and --margtimephi)\n\
118 (--margdist-comoving) Using marginalisation in distance with uniform-in-comoving-volume prior (compatible with --margphi and --margtimephi)\n\
129 fprintf(stdout,
"(--dof-%s DoF)\tDegrees of freedom for %s\n",ifo->
name,ifo->
name);
141 REAL8 nullLikelihood = 0.0;
153 fprintf(stderr,
"Using Student's T Likelihood.\n");
163 fprintf(stdout,
"Student-t Noise evidence %lf\n", noiseZ);
166 fprintf(stderr,
"Using marginalised phase likelihood.\n");
169 fprintf(stderr,
"Using marginalised time likelihood.\n");
172 fprintf(stderr,
"Using marginalised in time and phase likelihood.\n");
177 fprintf(stderr,
"Using ROQ in likelihood.\n");
181 fprintf(stderr,
"WARNING: Using Fast SineGaussian likelihood and WF for LIB.\n");
213 nullLikelihood = 0.0;
214 ifo = runState->
data;
215 while (ifo != NULL) {
222 for(t=0; t < runState->
nthreads; t++)
233 "deltaLogL",
"logL",
"deltaloglH1",
"deltaloglL1",
"deltaloglV1",
234 "logw",
"logPrior",
"hrss",
"loghrss", NULL};
247 intrinsicParams.
head = NULL;
251 while (*non_intrinsic_param) {
254 non_intrinsic_param++;
257 return intrinsicParams;
267 if(!array || !item)
return 0;
270 if(array[
i++]==item)
return 1;
287 REAL8 ra,dec,GPSdouble;
298 t0,alph,
theta,&GPSdouble,&ra,&dec);
339 double Fplus, Fcross;
342 double glitchReal=0.0, glitchImag=0.0;
345 int i,
j, lower, upper, ifo;
347 double ra=0.0, dec=0.0, psi=0.0, gmst=0.0;
348 double GPSdouble=0.0,
t0=0.0;
353 double deltaT, TwoDeltaToverN,
deltaF, twopit=0.0, re, im, dre, dim, newRe, newIm;
357 double amp_prefactor=1.0;
366 UINT4 spcal_active = 0;
369 REAL8 cos_calpha=cos(calpha);
370 REAL8 sin_calpha=sin(calpha);
371 UINT4 constantcal_active=0;
376 double dist_min, dist_max;
383 dist_max=exp(dist_max);
384 dist_min=exp(dist_min);
394 constantcal_active = 1;
396 if (spcal_active && constantcal_active){
397 fprintf(stderr,
"ERROR: cannot use spline and constant calibration error marginalization together. Exiting...\n");
400 if (model->
roq_flag && constantcal_active){
401 fprintf(stderr,
"ERROR: cannot use ROQ likelihood and constant calibration error marginalization together. Exiting...\n");
405 REAL8 degreesOfFreedom=2.0;
413 REAL8 desired_tc=0.0;
428 for(dataPtr=
data;dataPtr;dataPtr=dataPtr->
next) Nifos++;
429 void *generatedFreqModels[1+Nifos];
430 for(
i=0;
i<=Nifos;
i++) generatedFreqModels[
i]=NULL;
433 gsl_matrix *nparams = NULL;
435 gsl_matrix *psdBandsMin = NULL;
436 gsl_matrix *psdBandsMax = NULL;
439 gsl_matrix *glitchFD=NULL;
454 Nblock = (
int)nparams->size2;
460 double alpha[Nblock];
461 double lnalpha[Nblock];
463 double psdBandsMin_array[Nblock];
464 double psdBandsMax_array[Nblock];
478 int freq_length=0,time_length=0;
484 freq_length =
data->freqData->data->length;
485 time_length = 2*(freq_length-1);
518 fprintf(stderr,
"ERROR: Cannot use --detector-frame with less than 2 detectors!\n");
532 t0,alph,
theta,&GPSdouble,&ra,&dec);
555 GPSdouble = desired_tc;
559 if (dh_S_tilde ==NULL || dh_S == NULL)
562 for (
i = 0;
i < freq_length;
i++) {
563 dh_S_tilde->
data[
i] = 0.0;
570 if (dh_S_phase_tilde == NULL || dh_S_phase == NULL) {
574 for (
i = 0;
i < freq_length;
i++) {
575 dh_S_phase_tilde->
data[
i] = 0.0;
585 REAL8 loglikelihood = 0.0;
591 for(dataPtr=
data,ifo=0; dataPtr; dataPtr=dataPtr->
next,ifo++) {
603 REAL8 this_ifo_s = 0.0;
608 CHAR df_variable_name[320];
609 snprintf(df_variable_name,
sizeof(df_variable_name),
"df_%s",dataPtr->
name);
611 printf(
"Found variable %s\n",df_variable_name);
615 degreesOfFreedom = dataPtr->
STDOF;
617 if (!(degreesOfFreedom>0)) {
618 XLALPrintError(
" ERROR in StudentTLogLikelihood(): degrees-of-freedom parameter must be positive.\n");
636 else timeTmp = GPSdouble;
665 fprintf(stderr,
"Unhandled error in template generation - exiting!\n");
692 model->
roq->frequencyNodesLinear,
693 &(model->
roq->calFactorLinear),
694 model->
roq->frequencyNodesQuadratic,
695 &(model->
roq->calFactorQuadratic));
699 if (calFactor == NULL) {
714 if (constantcal_active){
716 sprintf(CA_A,
"%s_%s",
"calamp",dataPtr->
name);
722 sprintf(CP_A,
"%s_%s",
"calpha",dataPtr->
name);
727 cos_calpha=cos(calpha);
728 sin_calpha=-sin(calpha);
747 Fplus*=amp_prefactor;
748 Fcross*=amp_prefactor;
750 dataPtr->
fPlus = Fplus;
778 dim = -sin(twopit*
deltaF);
779 dre = -2.0*sin(0.5*twopit*
deltaF)*sin(0.5*twopit*
deltaF);
782 for(
i=0;
i<Nblock;
i++)
786 alpha[
i] = gsl_matrix_get(nparams,ifo,
i);
789 psdBandsMin_array[
i] = gsl_matrix_get(psdBandsMin,ifo,
i);
790 psdBandsMax_array[
i] = gsl_matrix_get(psdBandsMax,ifo,
i);
801 double complex weight_iii;
805 for(
unsigned int iii=0; iii < model->
roq->frequencyNodesLinear->length; iii++){
807 complex
double template_EI = model->
roq->calFactorLinear->data[iii] * (dataPtr->
fPlus*model->
roq->hptildeLinear->data->data[iii] + dataPtr->
fCross*model->
roq->hctildeLinear->data->data[iii] );
809 weight_iii = gsl_spline_eval (dataPtr->
roq->weights_linear[iii].spline_real_weight_linear, timeshift, dataPtr->
roq->weights_linear[iii].acc_real_weight_linear) + I*gsl_spline_eval (dataPtr->
roq->weights_linear[iii].spline_imag_weight_linear, timeshift, dataPtr->
roq->weights_linear[iii].acc_imag_weight_linear);
811 this_ifo_d_inner_h += ( weight_iii * ( conj( template_EI ) ) );
814 for(
unsigned int jjj=0; jjj < model->
roq->frequencyNodesQuadratic->length; jjj++){
816 this_ifo_s += dataPtr->
roq->weightsQuadratic[jjj] * creal( conj( model->
roq->calFactorQuadratic->data[jjj] * (model->
roq->hptildeQuadratic->data->data[jjj]*dataPtr->
fPlus + model->
roq->hctildeQuadratic->data->data[jjj]*dataPtr->
fCross) ) * ( model->
roq->calFactorQuadratic->data[jjj] * (model->
roq->hptildeQuadratic->data->data[jjj]*dataPtr->
fPlus + model->
roq->hctildeQuadratic->data->data[jjj]*dataPtr->
fCross) ) );
822 for(
unsigned int iii=0; iii < model->
roq->frequencyNodesLinear->length; iii++){
824 complex
double template_EI = dataPtr->
fPlus*model->
roq->hptildeLinear->data->data[iii] + dataPtr->
fCross*model->
roq->hctildeLinear->data->data[iii];
826 weight_iii = gsl_spline_eval (dataPtr->
roq->weights_linear[iii].spline_real_weight_linear, timeshift, dataPtr->
roq->weights_linear[iii].acc_real_weight_linear) + I*gsl_spline_eval (dataPtr->
roq->weights_linear[iii].spline_imag_weight_linear, timeshift, dataPtr->
roq->weights_linear[iii].acc_imag_weight_linear);
828 this_ifo_d_inner_h += weight_iii*conj(template_EI) ;
832 for(
unsigned int jjj=0; jjj < model->
roq->frequencyNodesQuadratic->length; jjj++){
833 complex
double template_EI = model->
roq->hptildeQuadratic->data->data[jjj]*Fplus + model->
roq->hctildeQuadratic->data->data[jjj]*Fcross;
835 this_ifo_s += dataPtr->
roq->weightsQuadratic[jjj] * creal( conj(template_EI) * (template_EI) );
839 d_inner_h += creal(this_ifo_d_inner_h);
844 Rcplx += 0.5*this_ifo_d_inner_h;
848 switch(marginalisationflags)
868 fprintf(stderr,
"variable name too long\n"); exit(1);
870 REAL8 this_ifo_snr = sqrt(this_ifo_s);
871 model->
ifo_SNRs[ifo] = this_ifo_snr;
876 fprintf(stderr,
"variable name too long\n"); exit(1);
878 REAL8 cplx_snr_amp = cabs(this_ifo_d_inner_h)/this_ifo_snr;
883 fprintf(stderr,
"variable name too long\n"); exit(1);
885 REAL8 cplx_snr_phase = carg(this_ifo_d_inner_h);
896 REAL8 templatesq=0.0;
897 REAL8 this_ifo_S=0.0;
900 for (
i=lower,chisq=0.0,re = cos(twopit*
deltaF*
i),im = -sin(twopit*
deltaF*
i);
902 i++,
psd++, hptilde++, hctilde++, dtilde++,
903 newRe = re + re*dre - im*dim,
904 newIm = im + re*dim + im*dre,
905 re = newRe, im = newIm)
913 if (constantcal_active) {
914 REAL8 dre_tmp= creal(d)*cos_calpha - cimag(d)*sin_calpha;
915 REAL8 dim_tmp = creal(d)*sin_calpha + cimag(d)*cos_calpha;
916 dre_tmp/=(1.0+calamp);
917 dim_tmp/=(1.0+calamp);
919 d=
crect(dre_tmp,dim_tmp);
920 sigmasq/=((1.0+calamp)*(1.0+calamp));
923 REAL8 singleFreqBinTerm;
929 for(
j=0;
j<Nblock;
j++)
931 if (
i >= psdBandsMin_array[
j] &&
i <= psdBandsMax_array[
j])
934 loglikelihood -= lnalpha[
j];
944 COMPLEX16 plainTemplate = Fplus*(*hptilde)+Fcross*(*hctilde);
947 template = plainTemplate * (re + I*im);
951 template =
template*calF;
962 glitchReal = gsl_matrix_get(glitchFD,ifo,2*
i);
963 glitchImag = gsl_matrix_get(glitchFD,ifo,2*
i+1);
964 COMPLEX16 glitch = glitchReal + I*glitchImag;
969 templatesq=creal(
template)*creal(
template) + cimag(
template)*cimag(
template);
970 REAL8 datasq = creal(d)*creal(d)+cimag(d)*cimag(d);
971 D+=TwoDeltaToverN*datasq/sigmasq;
972 this_ifo_S+=TwoDeltaToverN*templatesq/sigmasq;
973 COMPLEX16 dhstar = TwoDeltaToverN*d*conj(
template)/sigmasq;
974 this_ifo_Rcplx+=dhstar;
977 switch(marginalisationflags)
981 REAL8 diffsq = creal(diff)*creal(diff)+cimag(diff)*cimag(diff);
982 chisq = TwoDeltaToverN*diffsq/sigmasq;
983 singleFreqBinTerm = chisq;
990 REAL8 diffsq = creal(diff)*creal(diff)+cimag(diff)*cimag(diff);
991 chisq = TwoDeltaToverN*diffsq/sigmasq;
992 singleFreqBinTerm = ((degreesOfFreedom+2.0)/2.0) * log(1.0 + chisq/degreesOfFreedom) ;
1000 loglikelihood+=-TwoDeltaToverN*(templatesq+datasq)/sigmasq;
1006 dh_S_tilde->
data[
i] += TwoDeltaToverN * d * conj(
template) / sigmasq;
1010 dh_S_phase_tilde->
data[
i] += TwoDeltaToverN * d * conj(I*
template) / sigmasq;
1026 switch(marginalisationflags)
1046 fprintf(stderr,
"variable name too long\n"); exit(1);
1052 fprintf(stderr,
"variable name too long\n"); exit(1);
1054 REAL8 cplx_snr_amp=0.0;
1055 REAL8 cplx_snr_phase=carg(this_ifo_Rcplx);
1056 if(this_ifo_S > 0) cplx_snr_amp=2.0*cabs(this_ifo_Rcplx)/sqrt(2.0*this_ifo_S);
1062 fprintf(stderr,
"variable name too long\n"); exit(1);
1075 errnum&=~XLAL_EFUNC;
1085 fprintf(stderr,
"Unhandled error in marginal distance likelihood - exiting!\n");
1093 if (!(calFactor == NULL)) {
1104 REAL8 OptimalSNR=sqrt(S);
1105 REAL8 MatchedFilterSNR = d_inner_h/OptimalSNR;
1110 model->
SNR = OptimalSNR;
1124 m1 =
mc * pow(
q, -3.0/5.0) * pow(
q+1, 1.0/5.0);
1133 if( cos(tilt_spin1)*a_spin1 <= 0.4 - 7*
eta){
1136 loglikelihood = -1e15;
1144 switch(marginalisationflags)
1148 REAL8 R = 2.0*cabs(Rcplx);
1149 REAL8 phase_maxL = carg(Rcplx);
1150 if(phase_maxL<0.0) phase_maxL=
LAL_TWOPI+phase_maxL;
1153 gsl_sf_result result;
1155 if(GSL_SUCCESS==gsl_sf_bessel_I0_scaled_e(R, &result))
1159 else printf(
"ERROR: Cannot calculate I0(%lf)\n",R);
1161 loglikelihood += -(S+D) + log(I0x) + R ;
1167 errnum&=~XLAL_EFUNC;
1173 loglikelihood = -INFINITY;
1176 fprintf(stderr,
"Unhandled error in marginal distance likelihood - exiting!\n");
1182 loglikelihood -= D ;
1183 REAL8 distance_maxl = 2.0*S/R;
1191 d_inner_h = creal(Rcplx);
1195 errnum&=~XLAL_EFUNC;
1201 loglikelihood = -INFINITY;
1204 fprintf(stderr,
"Unhandled error in marginal distance likelihood - exiting!\n");
1210 loglikelihood -= D ;
1211 REAL8 distance_maxl = S/d_inner_h;
1221 dh_S_tilde->
data[0] =
crect( creal(dh_S_tilde->
data[0]), 0. );
1226 dh_S_phase_tilde->
data[0] =
crect( creal(dh_S_phase_tilde->
data[0]), 0.0);
1230 REAL8 time_low,time_high;
1235 if(iend > (
int) dh_S->
length || istart < 0 ) {
1236 fprintf(stderr,
"ERROR: integration over time extends past end of buffer! Is your time prior too wide?\n");
1245 for (
i = istart;
i < iend;
i++) {
1249 angMax = atan2(dh_S_phase->
data[
i], dh_S->
data[
i]);
1256 errnum&=~XLAL_EFUNC;
1262 dh_S->
data[
i] = -INFINITY;
1265 fprintf(stderr,
"Unhandled error in marginal distance likelihood - exiting!\n");
1274 double I0=log(gsl_sf_bessel_I0_scaled(
x)) + fabs(
x);
1283 for (
i = istart;
i < iend;
i++)
1286 errnum&=~XLAL_EFUNC;
1292 dh_S->
data[
i] = -INFINITY;
1295 fprintf(stderr,
"Unhandled error in marginal distance likelihood - exiting!\n");
1312 REAL8 phase_maxL=angMax;
1313 if(phase_maxL<0.0) phase_maxL=
LAL_TWOPI+phase_maxL;
1316 d_inner_h= 0.5*xMax;
1317 REAL8 distance_maxl = 2.0*S/xMax;
1322 d_inner_h=0.5*dh_S->
data[imax+istart];
1326 REAL8 distance_maxl = 2.0*S/xMax;
1344 REAL8 OptimalSNR=sqrt(2.0*S);
1345 REAL8 MatchedFilterSNR = 0.;
1349 if (OptimalSNR > 0.)
1350 MatchedFilterSNR = 2.0*d_inner_h/OptimalSNR;
1356 REAL8 coherence=loglikelihood + D;
1358 for(dataPtr=
data,ii=0;dataPtr;dataPtr=dataPtr->
next,ii++)
1361 sprintf(varname,
"%s_optimal_snr",dataPtr->
name);
1401 loglikelihood = -INFINITY;
1405 return(loglikelihood);
1410 static const size_t default_log_radial_integrator_size = 400;
1411 double loglikelihood=0;
1412 static double log_norm = 0;
1415 double pmax = 100000;
1416 #pragma omp critical
1418 if (integrator == NULL)
1420 printf(
"Initialising distance integration lookup table\n");
1428 default_log_radial_integrator_size * 5,
1435 if (!integrator)
XLAL_ERROR(
XLAL_EFUNC,
"Unable to initialise distance marginalisation integrator");
1437 if (isnan(OptimalSNR) || isnan(d_inner_h) || pmax<OptimalSNR)
1439 loglikelihood=-INFINITY;
1445 loglikelihood = marg_l - log_norm;
1447 return (loglikelihood);
1494 if (dataPtr==NULL || freqData1 ==NULL || freqData2==NULL){
1498 int lower, upper,
i;
1509 for (
i=lower;
i<=upper; ++
i){
1510 overlap += ((4.0*
deltaF*(creal(freqData1->
data[
i])*creal(freqData2->
data[
i])+cimag(freqData1->
data[
i])*cimag(freqData2->
data[
i])))
1521 if (dataPtr==NULL || freqData1 ==NULL || freqData2==NULL){
1525 int lower, upper,
i;
1536 for (
i=lower;
i<=upper; ++
i){
1546 REAL8 loglikelihood, totalChiSquared=0.0;
1550 while (ifoPtr != NULL) {
1553 totalChiSquared+=
temp;
1555 ifoPtr = ifoPtr->
next;
1557 loglikelihood = -0.5 * totalChiSquared;
1558 return(loglikelihood);
1590 double log_integral = -INFINITY;
1591 double max=-INFINITY;
1593 double log_imean_l=-INFINITY;
1594 double log_h = log(h);
1596 for (
i = 1;
i <
n-1;
i++) {
1597 log_integral =
logaddexp(log_integral, log_ys[
i]);
1598 log_imean_l =
logaddexp(log_imean_l, log(
i) + log_ys[
i]);
1600 if (log_ys[
i] >
max) {
1606 log_integral =
logaddexp(log_integral, log(0.5) + log_ys[0]);
1607 log_integral =
logaddexp(log_integral, log(0.5) + log_ys[
n-1]);
1610 log_imean_l =
logaddexp(log_imean_l, log(0.5) + log(
n-1) + log_ys[
n-1]);
1612 log_integral += log_h;
1613 log_imean_l += log_h;
1615 if (creal(log_ys[0]) >
max) {
1620 if (log_ys[
n-1] >
max) {
1625 log_imean_l -= log_integral;
1627 if(imean) *imean=exp(log_imean_l-log_integral);
1628 if(imax) *imax=imax_l;
1630 return log_integral;
1670 double Fplus, Fcross;
1671 int i, lower, upper, ifo;
1673 double ra=0.0, dec=0.0, psi=0.0, gmst=0.0;
1674 double GPSdouble=0.0;
1678 double deltaT, TwoDeltaToverN,
deltaF, twopit=0.0, re, im, dre, dim, newRe, newIm;
1681 double amp_prefactor=1.0;
1690 for(dataPtr=
data;dataPtr;dataPtr=dataPtr->
next) Nifos++;
1691 void *generatedFreqModels[1+Nifos];
1692 for(
i=0;
i<=Nifos;
i++) generatedFreqModels[
i]=NULL;
1716 fprintf(stderr,
"ERROR: Cannot use --detector-frame with less than 2 detectors!\n");
1723 t0,alph,
theta,&GPSdouble,&ra,&dec);
1734 REAL8 loglikelihood = 0.0;
1740 for(dataPtr=
data,ifo=0; dataPtr; dataPtr=dataPtr->
next,ifo++) {
1763 else timeTmp = GPSdouble;
1772 errnum&=~XLAL_EFUNC;
1781 fprintf(stderr,
"Unhandled error in template generation - exiting!\n");
1802 Fplus*=amp_prefactor;
1803 Fcross*=amp_prefactor;
1805 dataPtr->
fPlus = Fplus;
1806 dataPtr->
fCross = Fcross;
1824 dim = -sin(twopit*
deltaF);
1825 dre = -2.0*sin(0.5*twopit*
deltaF)*sin(0.5*twopit*
deltaF);
1833 INT4 upppone=upper+1;
1834 for (
i=lower,chisq=0.0,re = cos(twopit*
deltaF*
i),im = -sin(twopit*
deltaF*
i);
1836 i++,
psd++, hptilde++, hctilde++, dtilde++,
1837 newRe = re + re*dre - im*dim,
1838 newIm = im + re*dim + im*dre,
1839 re = newRe, im = newIm)
1847 COMPLEX16 plainTemplate = Fplus*(*hptilde)+Fcross*(*hctilde);
1850 template = plainTemplate * (re + I*im);
1851 diff = (d -
template);
1853 REAL8 diffsq = creal(diff)*creal(diff)+cimag(diff)*cimag(diff);
1854 chisq = TwoDeltaToverN*diffsq/sigmasq;
1862 return(loglikelihood);
1879 double Fplus, Fcross;
1880 REAL8 plainTemplateReal, plainTemplateImag;
1881 int i, lower, upper, ifo;
1883 double ra=0.0, dec=0.0, psi=0.0, gmst=0.0;
1884 double GPSdouble=0.0;
1891 INT4 remove_time = 0;
1896 for(dataPtr=
data;dataPtr;dataPtr=dataPtr->
next) Nifos++;
1897 void *generatedFreqModels[1+Nifos];
1898 for(
i=0;
i<=Nifos;
i++) generatedFreqModels[
i]=NULL;
1914 while (dataPtr != NULL) {
1917 dataPtr = dataPtr->
next;
1940 fprintf(stderr,
"ERROR: Cannot use --detector-frame with less than 2 detectors!\n");
1947 t0,alph,
theta,&GPSdouble,&ra,&dec);
1961 UINT4 freq_length =
data->freqData->data->length;
1962 UINT4 time_length = 2*(freq_length-1);
1964 GPSdouble =
epoch + (time_length-1)*
data->timeData->deltaT - 2.0;
1973 while (dataPtr != NULL) {
1991 else timeTmp = GPSdouble;
1998 double pi2 = M_PI / 2.0;
2003 errnum&=~XLAL_EFUNC;
2012 fprintf(stderr,
"Unhandled error in template generation - exiting!\n");
2031 dataPtr->
fPlus = Fplus;
2032 dataPtr->
fCross = Fcross;
2041 for (
i=lower;
i<=upper; ++
i){
2057 dataPtr = dataPtr->
next;
2063 model->
SNR = sqrt(model->
SNR);
static double integrate_interpolated_log(double h, REAL8 *log_ys, size_t n, double *imean, size_t *imax)
Integrate interpolated log, returns the mean index in *imax if it is not a NULL pointer.
static int checkItemAndAdd(void *item, void **array)
REAL8 LALInferenceZeroLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData UNUSED *data, LALInferenceModel UNUSED *model)
For testing purposes (for instance sampling the prior), likelihood that returns 0....
LALInferenceLikelihoodFlags
static int get_calib_spline(LALInferenceVariables *vars, const char *ifoname, REAL8Vector **logfreqs, REAL8Vector **amps, REAL8Vector **phases)
static REAL8 LALInferenceFusedFreqDomainLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model, LALInferenceLikelihoodFlags marginalisationflags)
const char * non_intrinsic_params[]
LALInferenceVariables currentParams
double log_radial_integrator_eval(const log_radial_integrator *integrator, double p, double b, double log_p, double log_b)
Evaluate the log distance integrator for given SNRs.
log_radial_integrator * log_radial_integrator_init(double r1, double r2, int k, int cosmology, double pmax, size_t size, int gaussian)
Distance integrator for marginalisation.
void XLALComputeDetAMResponse(double *fplus, double *fcross, const REAL4 D[3][3], const double ra, const double dec, const double psi, const double gmst)
COMPLEX16FrequencySeries * XLALCreateCOMPLEX16FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
void XLALDestroyCOMPLEX16FrequencySeries(COMPLEX16FrequencySeries *series)
UINT4 LALInferenceGetUINT4Variable(LALInferenceVariables *vars, const char *name)
int LALInferenceSplineCalibrationFactorROQ(REAL8Vector *logfreqs, REAL8Vector *deltaAmps, REAL8Vector *deltaPhases, REAL8Sequence *freqNodesLin, COMPLEX16Sequence **calFactorROQLin, REAL8Sequence *freqNodesQuad, COMPLEX16Sequence **calFactorROQQuad)
Modified version of LALInferenceSplineCalibrationFactor to compute the calibration factors for the sp...
void LALInferenceAddVariable(LALInferenceVariables *vars, const char *name, const void *value, LALInferenceVariableType type, LALInferenceParamVaryType vary)
Add a variable named name to vars with initial value referenced by value.
REAL8 LALInferenceGetREAL8Variable(LALInferenceVariables *vars, const char *name)
void LALInferenceExecuteFT(LALInferenceModel *model)
Execute FFT for data in IFOdata.
void LALInferenceRemoveVariable(LALInferenceVariables *vars, const char *name)
Remove name from vars Frees the memory for the name structure and its contents.
void LALInferenceCopyVariables(LALInferenceVariables *origin, LALInferenceVariables *target)
Deep copy the variables from one to another LALInferenceVariables structure.
void * LALInferenceGetVariable(const LALInferenceVariables *vars, const char *name)
Return a pointer to the memory the variable vars is stored in specified by name User must cast this p...
void LALInferenceAddREAL8Variable(LALInferenceVariables *vars, const char *name, REAL8 value, LALInferenceParamVaryType vary)
INT4 LALInferenceGetINT4Variable(LALInferenceVariables *vars, const char *name)
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
void(* LALInferenceTemplateFunction)(struct tagLALInferenceModel *model)
Type declaration for template function, which operates on a LALInferenceIFOData structure *data.
void LALInferenceBinaryLove(LALInferenceVariables *vars, REAL8 *lambda1, REAL8 *lambda2)
Compute Tidal deformabilities following BinaryLove Universal relations.
int LALInferenceSplineCalibrationFactor(REAL8Vector *logfreqs, REAL8Vector *deltaAmps, REAL8Vector *deltaPhases, COMPLEX16FrequencySeries *calFactor)
Computes the factor relating the physical waveform to a measured waveform for a spline-fit calibratio...
void LALInferenceDetFrameToEquatorial(LALDetector *det0, LALDetector *det1, REAL8 t0, REAL8 alpha, REAL8 theta, REAL8 *tg, REAL8 *ra, REAL8 *dec)
Conversion routines between Equatorial (RA,DEC) and detector-based coordinate systems,...
int LALInferenceCheckVariable(LALInferenceVariables *vars, const char *name)
Checks for name being present in vars returns 1(==true) or 0.
@ LALINFERENCE_PARAM_OUTPUT
A parameter that never changes, functions should respect this.
@ LALINFERENCE_PARAM_FIXED
A parameter that is cyclic, such as an angle between 0 and 2pi.
@ LALINFERENCE_PARAM_LINEAR
REAL8 LALInferenceBimodalCorrelatedAnalyticLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
An analytic likeilhood that is two correlated Gaussians in 15 dimensions.
REAL8 LALInferenceCorrelatedAnalyticLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
An analytic likeilhood that is a correlated Gaussian in 15 dimensions.
REAL8 LALInferenceMarginalisedTimePhaseLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
void LALInferenceInitLikelihood(LALInferenceRunState *runState)
Initialisation function which reads runState->commaneLine and sets up the likelihood function accordi...
REAL8 LALInferenceNullLogLikelihood(LALInferenceIFOData *data)
Identical to LALInferenceFreqDomainNullLogLikelihood, but returns the likelihood of a null template.
double LALInferenceMarginalDistanceLogLikelihood(double dist_min, double dist_max, double OptimalSNR, double d_inner_h, int cosmology, int margphi)
Compute delta-log-likelihood for given distance min, max and OptimalSNR and d_inner_h when evaluated ...
REAL8 LALInferenceFreqDomainStudentTLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
Student-t (log-) likelihood function as described in Roever/Meyer/Christensen (2011): "Modelling colo...
COMPLEX16 LALInferenceComputeFrequencyDomainComplexOverlap(LALInferenceIFOData *dataPtr, COMPLEX16Vector *freqData1, COMPLEX16Vector *freqData2)
Computes the complex <x|y> overlap.
REAL8 LALInferenceFastSineGaussianLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
fast SineGaussian likelihood for LIB
REAL8 LALInferenceMarginalisedTimeLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
Returns the log-likelihood marginalised over the time dimension from the prior min to the prior max.
REAL8 LALInferenceComputeFrequencyDomainOverlap(LALInferenceIFOData *dataPtr, COMPLEX16Vector *freqData1, COMPLEX16Vector *freqData2)
Computes the <x|y> overlap in the Fourier domain.
REAL8 LALInferenceUndecomposedFreqDomainLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
(log-) likelihood function.
void LALInferenceNetworkSNR(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
Calculate the SNR across the network.
REAL8 LALInferenceMarginalisedPhaseLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
REAL8 LALInferenceRosenbrockLogLikelihood(LALInferenceVariables *currentParams, LALInferenceIFOData *data, LALInferenceModel *model)
15-D Rosenbrock log(L) function (see Eq (3) of http://en.wikipedia.org/wiki/Rosenbrock_function .
LALInferenceVariables LALInferenceGetInstrinsicParams(LALInferenceVariables *currentParams)
Get the intrinsic parameters from currentParams.
void LALInferenceGetMinMaxPrior(LALInferenceVariables *priorArgs, const char *name, REAL8 *min, REAL8 *max)
Get the minimum and maximum values of the uniform prior from the priorArgs list, given a name.
void LALInferenceTemplateNullFreqdomain(LALInferenceModel *model)
Returns a frequency-domain 'null' template (all zeroes, implying no signal present).
void LALInferenceTemplateNullTimedomain(LALInferenceModel *model)
Returns a time-domain 'null' template (all zeroes, implying no signal present).
int XLALREAL8ReverseFFT(REAL8Vector *output, const COMPLEX16Vector *input, const REAL8FFTPlan *plan)
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
const LALUnit lalDimensionlessUnit
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
void XLALDestroyCOMPLEX16Vector(COMPLEX16Vector *vector)
const char * XLALErrorString(int errnum)
#define XLAL_ERROR_REAL8(...)
#define XLAL_CHECK_ABORT(assertion)
#define XLAL_TRY(statement, errnum)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
static double logaddexp(double x, double y)
Structure to contain IFO data.
REAL8TimeSeries * timeData
Detector name.
LALDetector * detector
integration limits for overlap integral in F-domain
REAL8FrequencySeries * oneSidedNoisePowerSpectrum
REAL8 timeshift
Detector responses.
struct tagLALInferenceROQData * roq
counts how many time the template has been calculated
COMPLEX16FrequencySeries * freqData
What is this?
REAL8 nullloglikelihood
A time series of the data noise variance.
struct tagLALInferenceIFOData * next
ROQ data.
REAL8 fLow
FFT plan needed for time/time-and-phase marginalisation.
REAL8 STDOF
IF INJECTION ONLY, E(SNR) of the injection in the detector.
Structure to constain a model and its parameters.
REAL8 * ifo_loglikelihoods
Network SNR at params
REAL8 * ifo_SNRs
Array of single-IFO likelihoods at params
COMPLEX16FrequencySeries * freqhPlus
Time series model buffers.
REAL8 SNR
Likelihood value at params
LALInferenceVariables * params
COMPLEX16FrequencySeries * freqhCross
struct tagLALInferenceROQModel * roq
The padding of the above window.
LALInferenceTemplateFunction templt
Domain of model.
LALSimulationDomain domain
IFO-dependent parameters and buffers.
Structure containing inference run state This includes pointers to the function types required to run...
ProcessParamsTable * commandLine
LALInferenceVariables * proposalArgs
The data from the interferometers.
LALInferenceVariables * algorithmParams
Any special arguments for the prior function.
INT4 nthreads
Array of live points for Nested Sampling.
struct tagLALInferenceIFOData * data
Log sample, i.e.
LALInferenceThreadState * threads
LALInferenceLikelihoodFunction likelihood
MultiNest prior for the parameters.
Structure containing chain-specific variables.
LALInferenceVariables * currentParams
Prior boundaries, etc.
LALInferenceModel * model
Cycle of proposals to call.
REAL8 nullLikelihood
Array storing network SNR of current sample.
The LALInferenceVariables structure to contain a set of parameters Implemented as a linked list of LA...
LALInferenceVariableItem * head