Source
xxxxxxxxxx
errorMsg = "Could not fit a Poisson distribution because the lambda value: "+lambdaStr+" was outside data range.";
//# Copyright (C) 2005
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
using namespace casacore;
namespace casa {
FitterPoisson::FitterPoisson() {
clearFit();
}
void FitterPoisson::clearFit(){
Fitter::clearFit();
lambdaSpecified = false;
}
float FitterPoisson::getFitCount() const {
float count = 0;
for ( int i = 0; i < static_cast<int>(actualYValues.size()); i++ ){
if ( actualYValues[i] > count ){
float binCount = actualYValues[i];
count = count + binCount;
}
}
return count;
}
void FitterPoisson::restrictDomain( double xMin, double xMax ){
//Negative values don't make sense for a Poisson distribution.
domainMin = qMax( 0.0, xMin );
domainMax = qMax( 0.0, xMax );
resetDataWithLimits();
}
QString FitterPoisson::getSolutionStatistics() const {
QString result;
if ( solutionConverged ){
result.append( "The following fit was found:\n\n");
result.append( formatResultLine( "Lambda:", actualLambda, false)+ " "+ units + "\n");
//result.append( formatResultLine( "Fit Count:", solutionHeight));
result.append( formatResultLine( "Chi-square:", solutionChiSquared));
int count = actualXValues.size();
result.append( formatResultLine( "Degrees of Freedom:", count));
}
else {
result.append( "Fit did not converge.\n");
}
return result;
}
pair<double,double> FitterPoisson::_getMinMax() const {
int xCount = actualXValues.size();
pair<double,double> minMax(-1,-1 );
if ( xCount > 0 ){
minMax.first = actualXValues[0];
minMax.second = actualXValues[xCount - 1];
}
return minMax;
}