#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <math.h>
#include "nr.h"
#include "nrutil.h"

#define NBINS 1

int main(void)
{
	int i,ibin,j;
	float chsq,df,prob,x,*bins,*ebins;

	bins=vector(1,NBINS);
	ebins=vector(1,NBINS);
	cout<<"Please input the observed number of events\n";
	for(i=1;i<=NBINS;i++) cin>>bins[i];
	cout<<"Please input the expected number of events\n";
	for(i=1;i<=NBINS;i++) cin>>ebins[i];

/*	chsone(bins,ebins,NBINS, 1,&df,&chsq,&prob);
	printf("%15s %15s\n","expected","observed");
	for(i=1;i<=NBINS;i++) printf("%14.2f %15.2f\n",ebins[i],bins[i]);
	printf("\n%19s %10.4f\n","chi-square:",chsq);
*/
	prob=gammq(0.5*bins[1],0.5*ebins[1]);
	printf("%19s %10.5e\n","probability:",prob);
	free_vector(ebins,1,NBINS);
	free_vector(bins,1,NBINS);
	return 0;
}
