6 #include <lal/LALConstants.h>
7 #include <lal/Skymap.h>
8 #include <lal/Random.h>
12 #define UNUSED __attribute__ ((unused))
41 for (
a[0] = -5.0;
a[0] <= 5.0;
a[0] += da)
43 for (
a[1] = - 5.0;
a[1] <= 5.0;
a[1] += da)
48 double q = (
a[0] *
a[0] +
a[1] *
a[1]);
52 for (j = 0; j != plan->
n; ++j)
59 q -=
x[j] *
x[j] / wSw[j];
61 for (k = 0; k != 2; ++k)
64 x[j] -=
a[k] * properties->
f[j][k] * wSw[j];
67 q +=
x[j] *
x[j] / wSw[j];
70 p += da * da * exp(-0.5*
q);
78 *logPosterior = log(
p);
87 double wSw[5] = { 100., 100., 100., 100., 100. };
96 for (n = 1; n != 6; ++n)
111 for (i = 0; i != n; ++i)
123 double logPosteriorAnalytic;
124 double logPosteriorNumerical;
126 XLALSkymapApply(&plan, &properties, &kernel, xSw, 0.5, &logPosteriorAnalytic);
128 numericApply(&plan, &properties, wSw, &kernel, xSw, 0.5, & logPosteriorNumerical);
130 if (fabs(logPosteriorAnalytic - logPosteriorNumerical) > 1e-3)
132 fprintf(stderr,
"Analytic expression does not match numerical result to expected accuracy\n");
140 for(i = 0; i != n; ++i)
155 x = (
double*) malloc(
sizeof(
double) * n);
157 for (
int i = 0; i != n; ++i)
162 for (
double t = n * 0.25; t < n * 0.75; t += 0.1)
166 fprintf(stderr,
"Interpolation error larger than expected\n");
171 for (
int t = n / 4; t < (n * 3) / 4; ++t)
175 fprintf(stderr,
"Interpolation does not pass through data points\n");
190 double wSw[5] = { 100., 100., 100., 100., 100. };
192 double error[5] = { 0., 0., 0., 0., 0. };
200 for (n = 3; n != 4; ++n)
211 for (
int i = 0; i != n; ++i)
213 for (
int j = 0; j != n; ++j)
216 if (fabs(kernel.
k[i][j] - kernel2.
k[i][j]) > 1e-10)
218 fprintf(stderr,
"Loose kernel does not match simple kernel for zero error\n");
227 fprintf(stderr,
"Loose normalization does not match simple normalization for zero error\n");
void XLALSkymapDirectionPropertiesConstruct(XLALSkymapPlanType *plan, double directions[2], XLALSkymapDirectionPropertiesType *properties)
void XLALSkymapUncertainKernelConstruct(XLALSkymapPlanType *plan, XLALSkymapDirectionPropertiesType *properties, double *wSw, double *error, XLALSkymapKernelType *kernel)
double XLALSkymapInterpolate(double t, double *x)
void XLALSkymapApply(XLALSkymapPlanType *plan, XLALSkymapDirectionPropertiesType *properties, XLALSkymapKernelType *kernel, double **xSw, double tau, double *posterior)
void XLALSkymapPlanConstruct(int sampleFrequency, int n, int *detectors, XLALSkymapPlanType *plan)
void XLALSkymapKernelConstruct(XLALSkymapPlanType *plan, XLALSkymapDirectionPropertiesType *properties, double *wSw, XLALSkymapKernelType *kernel)
static void numericApply(XLALSkymapPlanType *plan, XLALSkymapDirectionPropertiesType *properties, double *wSw, XLALSkymapKernelType UNUSED *kernel, double **xSw, double tau, double *logPosterior)
static void numerical(void)
static void uncertain(void)
static void interpolation(void)
static REAL8TimeSeries * error(const REAL8TimeSeries *s1, const REAL8TimeSeries *s0)
#define LAL_REAL8_EPS
Difference between 1 and the next resolvable REAL8 2^-52.
#define LAL_PI
Archimedes's constant, pi.
#define LAL_TWOPI
2*pi is circumference of a circle divided by its radius
REAL4 XLALNormalDeviate(RandomParams *params)
RandomParams * XLALCreateRandomParams(INT4 seed)
REAL4 XLALUniformDeviate(RandomParams *params)
This structure contains the parameters necessary for generating the current sequence of random number...
double f[XLALSKYMAP_N][2]
double delay[XLALSKYMAP_N]
double k[XLALSKYMAP_N][XLALSKYMAP_N]