/** 
* @file FitSigmoid.h
* @brief fit a sigmoid function accordings to the paper of platt
* @author Erik Rodner
* @date 03/05/2009

*/
#ifndef FITSIGMOIDINCLUDE
#define FITSIGMOIDINCLUDE

#include <vector>
  

namespace OBJREC {

/** fit a sigmoid function accordings to the paper of platt */
class FitSigmoid
{
    public:
 
	/** fit a sigmoid function f(t) = out = 1/(1+exp(A*t+B))
	   @param t input values
	   @param out output values
	   @param startp initial value of f(t)
	   @param A initial value of A
	   @param B initial value of B
	*/
	static void fitSigmoid ( const std::vector<double> & t,
		  const std::vector<double> & out,
		  double startp,
		  double & A, double & B );
    
	/** fit a sigmoid function using fitSigmoid to results of a binary 
	    classifier (e.g. svm), 1/(1+exp(A*t+B))
	    @param results classifier results
	    @param A final parameter A
	    @param B final parameter B
	    @param mlestimation perform ML-estimation or MAP-estimation (cf. Platt)
	*/
	static void fitProbabilities ( const std::vector<std::pair<int, double> > & results, 
	     double & A, double & B, double mlestimation = false );

};


} // namespace

#endif
