I have an equation like so:
z = Sum of a = 1 to n [ e**(y - x(a))/ e**(x(a)]
I want to solve for y.
I have z and x(a).
I have created a class EquationSolver which has these methods and inner
class:
private EstimatedParameter xa;
public VintageQualityFitter() {
xa = new EstimatedParameter("xa", 0.0);
// provide the parameters to the base class which
// implements the getAllParameters and getUnboundParameters methods
addParameter(xa);
}
public double theoreticalValue(double z) {
double summand = ( Math.exp(y * xa.getEstimate()) /
Math.exp(xa.getEstimate());
return summand;
}
public void addPoint(double xa) {
addMeasurement(new LocalMeasurement(xa, 1.0)); // all weights same
}
public double getXa() {
return xa.getEstimate();
}
private class LocalMeasurement extends WeightedMeasurement {
private final double z;
// constructor
public LocalMeasurement(double xa, double weight) {
super(xa, weight);
this.z = xa;
}
public double getTheoreticalValue() {
// the value is provided by the model for the local xa
return theoreticalValue(z);
}
// don't need this i think
public double getPartial(EstimatedParameter parameter) {
return 0.0;
}
}
I use this like so:
EquationFitter equationFitter = new EquationFitter();
for (int a = 0; a <= numberOfAs; a++) {
double xa = <get x(a)>
equationFitter.addPoint(xa.doubleValue());
}
try {
// solve the problem, using a Levenberg-Marquardt algorithm with
default settings
LevenbergMarquardtEstimator estimator = new
LevenbergMarquardtEstimator();
estimator.estimate(equationFitter);
} catch (EstimationException e) {
e.printStackTrace();
}
// fitter.theoreticalValue() is alpha
<get some z>
y = equationFitter.theoreticalValue(z);
but something in all this isn't right, especially with theoreticalValue(),
i think.
Can anyone help?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]