Show page source of ClassVfunc #17272

== ClassVfunc : Model of the Vector Function with parameters ==
{{{ code java
 *[class] Vfunc              5/20/2008 by Classiclll
 *
 * Model of the Vector Function with parameters
 *	f : R^n.R^m -> R
 *
 * can solve the followings with Simplex(Nelder) and Newton
 *		for given p, find x such that f(x;p) = 0
 *		for given p, find extreme point x* such that f(x*;p)/dx = 0
 *		estimate parameters p* such that ssr(obs,samples,p*)/dp = 0
 *			based the observations, {obs[i] in R, samples[i] in R^n}
 *
 Vfunc(int domX, int domP) // construct 
 			//	& setup the internal inplementations of EqSys as solver

 int domDim() {return domX;} 		// dimension of the domain (n)
 int paramDim() {return domP;}		// dimension of the params (m)

 abstract double valueAt(Vec x, Vec p)	// this parameterized function (R^n.R^m -> R)
 abstract Vec gradAt(Vec x, Vec p)	// this gradient arround x, given p
 abstract Vec gradParamAt(Vec x, Vec p)	// this gradient arround p, given x

 double valueAt(Vec x) 	// conbinient method with no parameters.
 Vec gradAt(Vec x) 	// conbinient method with no parameters.
 
 Vec diffAt(Vec x, Vec d, Vec p) 	// gradient estimator at x+d using valueAt() 
 Vec diffParamAt(Vec x, Vec d, Vec p)// param grad estimator at p+d using valueAt()

 // 1. for solving the equation of this function.
  	private class thisEqSys extends EqSys  // an implementation of Equation System
 Vec solveByNewton(Vec x0, Vec p)  // find the solution by newton, start at x0
 Vec solveBySimplex(Vec x0, Vec p, int limit) // find the solution by Simplex, start at x0

 // 2. for finding of the extreme point of this function
  	private class gradEqSys extends EqSys // an implementation of Equation System
  	//find one extreme point, start at x0
 Vec findeExtremeByNewton(Vec x0, Vec p)
 Vec findeExtremeBySimplex(Vec x0, Vec p, int limit)
 Vec findeExtremeBySimplex(Vec x0, Vec p, int limit, int tryal)

 // 3. least sqare equation system based by the Square Sum of Residual
  	private class paramEqSys extends EqSys // an implementation of Equation System
 	// estimate the params by Least Square Sum
 Vec bestPrmByNewton(Vec p, Vec obs, Mat samples)
 Vec bestPrmBySimplex(Vec p, Vec obs, Mat samples, int limit)
 Vec bestPrmBySimplex(Vec p, Vec obs, Mat samples, int limit, int tryal)
 	// the Formulation for the Least Square Sum of the Sum of Square residuals
 double ssrAt(Vec p, Vec obs, Mat samples) //calcurate the Square Sum of Residuals at "p".
 Vec residual(Vec p, Vec obs, Mat samples) // calculate the each residual at "p"
 Vec ssrGradAt(Vec p, Vec obs, Mat samples) // gradient of ssr based gradParamAt()
 Vec ssrJacobAt(Vec p, Vec obs, Mat samples) // jacobian of ssr based gradParamAt()
}}}