/* ========================================================================== baseball.c -- an auxiliary program for use with the amcmc package Copyright (c) 2007 by Jeffrey S. Rosenthal (probability.ca/jeff) Instructions for use at: probability.ca/amcmc Licensed for general copying, distribution and modification according to the GNU General Public License (www.gnu.org/copyleft/gpl.html). ========================================================================== */ #include /* Define the dimension to be 20: */ int mydim() { return(20); } /* Define the functional to be simply the first coordinate: */ double myfunctional( double *theargs ) { return( theargs[0] ); } /* Prior values. */ #define a1 -1 #define a2 -1 #define b1 2 #define b2 2 #define mu0 0 #define s0 1 #define MYINFINITY 999999999.9 /* Define the (complicated) target log density function: */ double mydensity( double t[] ) { double result, A, V, mu; int kk; double Y[18]; /* Data values */ Y[0] = 0.395; Y[1] = 0.375; Y[2] = 0.355; Y[3] = 0.334; Y[4] = 0.313; Y[5] = 0.313; Y[6] = 0.291; Y[7] = 0.269; Y[8] = 0.247; Y[9] = 0.247; Y[10] = 0.224; Y[11] = 0.224; Y[12] = 0.224; Y[13] = 0.224; Y[14] = 0.224; Y[15] = 0.200; Y[16] = 0.175; Y[17] = 0.148; /* Extract variables from arguments. */ mu = t[18]; A = t[19]; V = 0.00434; /* Check for out of range values. */ if ( (A<0) || (V<0) ) return(-MYINFINITY); /* Do the computation. */ result = -(mu-mu0)*(mu-mu0) / 2.0 / s0 / s0 - b1/A - (a1+1) * log(A) - b2/V - (a2+1) * log(V); for (kk=0; kk<18; kk++) result = result - 0.5 * log(A) - (t[kk]-mu)*(t[kk]-mu) / 2.0 / A - 0.5 * log(V) - (Y[kk]-t[kk])*(Y[kk]-t[kk]) / 2.0 / V; /* Return the result. */ return(result); }