package org.geogebra.common.kernel.statistics;
import org.geogebra.common.kernel.Kernel;
import org.geogebra.common.kernel.arithmetic.Command;
import org.geogebra.common.kernel.commands.CommandProcessor;
import org.geogebra.common.kernel.geos.GeoBoolean;
import org.geogebra.common.kernel.geos.GeoElement;
import org.geogebra.common.kernel.geos.GeoList;
import org.geogebra.common.kernel.geos.GeoNumeric;
import org.geogebra.common.main.MyError;
/**
* TEstimate (t confidence interval estimate of the difference of means)
*/
public class CmdTMean2Estimate extends CommandProcessor {
/**
* Create new command processor
*
* @param kernel
* kernel
*/
public CmdTMean2Estimate(Kernel kernel) {
super(kernel);
}
@Override
public GeoElement[] process(Command c) throws MyError {
int n = c.getArgumentNumber();
boolean[] ok = new boolean[n];
GeoElement[] arg;
arg = resArgs(c);
switch (n) {
case 4:
if ((ok[0] = arg[0].isGeoList()) && (ok[1] = arg[1].isGeoList())
&& (ok[2] = arg[2].isGeoNumeric())
&& (ok[3] = arg[3].isGeoBoolean())) {
AlgoTMean2Estimate algo = new AlgoTMean2Estimate(cons,
c.getLabel(), (GeoList) arg[0], (GeoList) arg[1],
(GeoNumeric) arg[2], (GeoBoolean) arg[3]);
GeoElement[] ret = { algo.getResult() };
return ret;
} else if (!ok[0]) {
throw argErr(app, c, arg[0]);
} else if (!ok[1]) {
throw argErr(app, c, arg[1]);
} else if (!ok[2]) {
throw argErr(app, c, arg[2]);
} else {
throw argErr(app, c, arg[3]);
}
case 8:
if ((ok[0] = arg[0].isGeoNumeric())
&& (ok[1] = arg[1].isGeoNumeric())
&& (ok[2] = arg[2].isGeoNumeric())
&& (ok[3] = arg[3].isGeoNumeric())
&& (ok[4] = arg[4].isGeoNumeric())
&& (ok[5] = arg[5].isGeoNumeric())
&& (ok[6] = arg[6].isGeoNumeric())
&& (ok[7] = arg[7].isGeoBoolean())) {
AlgoTMean2Estimate algo = new AlgoTMean2Estimate(cons,
c.getLabel(), (GeoNumeric) arg[0], (GeoNumeric) arg[1],
(GeoNumeric) arg[2], (GeoNumeric) arg[3],
(GeoNumeric) arg[4], (GeoNumeric) arg[5],
(GeoNumeric) arg[6], (GeoBoolean) arg[7]);
GeoElement[] ret = { algo.getResult() };
return ret;
} else if (!ok[0]) {
throw argErr(app, c, arg[0]);
} else if (!ok[1]) {
throw argErr(app, c, arg[1]);
} else if (!ok[2]) {
throw argErr(app, c, arg[2]);
} else if (!ok[3]) {
throw argErr(app, c, arg[3]);
} else if (!ok[4]) {
throw argErr(app, c, arg[4]);
} else if (!ok[5]) {
throw argErr(app, c, arg[5]);
} else if (!ok[6]) {
throw argErr(app, c, arg[6]);
} else {
throw argErr(app, c, arg[7]);
}
default:
throw argNumErr(app, c, n);
}
}
}