List of usage examples for org.apache.commons.math3.optim SimpleBounds unbounded
public static SimpleBounds unbounded(int dim)
From source file:com.itemanalysis.psychometrics.irt.equating.StockingLordMethodTest.java
@Test public void stockingLordTest3() { System.out.println("StockingLordMethod Test 3: Normal Distribution"); int n = aX.length; LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); ItemResponseModel irm;/*from w w w.j a v a2s .c om*/ for (int i = 0; i < n; i++) { String name = "V" + i; irm = new Irm3PL(aX[i], bX[i], cX[i], 1.0); irmX.put(name, irm); irm = new Irm3PL(aY[i], bY[i], cY[i], 1.0); irmY.put(name, irm); } NormalDistributionApproximation normal = new NormalDistributionApproximation(0, 1, -4, 4, 10); StockingLordMethod sl = new StockingLordMethod(irmX, irmY, normal, normal, EquatingCriterionType.Q1Q2); sl.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(sl), GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] slCoefficients = optimum.getPoint(); sl.setIntercept(slCoefficients[0]); sl.setScale(slCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + slCoefficients[0] + " A = " + slCoefficients[1]); assertEquals(" Intercept test", -0.4788, sl.getIntercept(), 1e-4); assertEquals(" Scale test", 1.0901, sl.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.StockingLordMethodTest.java
@Test public void stockingLordTest4() { System.out.println("StockingLordMethod Test 4: Actual Distribution -backwards"); int n = aX.length; LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); ItemResponseModel irm;/*from ww w . j a v a2 s . c o m*/ for (int i = 0; i < n; i++) { String name = "V" + i; irm = new Irm3PL(aX[i], bX[i], cX[i], 1.0); irmX.put(name, irm); irm = new Irm3PL(aY[i], bY[i], cY[i], 1.0); irmY.put(name, irm); } UserSuppliedDistributionApproximation distX = new UserSuppliedDistributionApproximation(points, xDensity); UserSuppliedDistributionApproximation distY = new UserSuppliedDistributionApproximation(points, yDensity); StockingLordMethod sl = new StockingLordMethod(irmX, irmY, distX, distY, EquatingCriterionType.Q1); sl.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(sl), GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] slCoefficients = optimum.getPoint(); sl.setIntercept(slCoefficients[0]); sl.setScale(slCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + slCoefficients[0] + " A = " + slCoefficients[1]); assertEquals(" Intercept test", -0.4834, sl.getIntercept(), 1e-4); assertEquals(" Scale test", 1.0967, sl.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.HaebaraMethodTest.java
@Test public void haebaraMethodTestMixedFormat() { System.out.println("Haebara Test 5: Mixed format test, symmetric"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //Form X/*ww w . j av a2 s. co m*/ irmX.put("v1", new Irm3PL(0.751335, -0.897391, 0.244001, 1.7)); irmX.put("v2", new Irm3PL(0.955947, -0.811477, 0.242883, 1.7)); irmX.put("v3", new Irm3PL(0.497206, -0.858681, 0.260893, 1.7)); irmX.put("v4", new Irm3PL(0.724000, -0.123911, 0.243497, 1.7)); irmX.put("v5", new Irm3PL(0.865200, 0.205889, 0.319135, 1.7)); irmX.put("v6", new Irm3PL(0.658129, 0.555228, 0.277826, 1.7)); irmX.put("v7", new Irm3PL(1.082118, 0.950549, 0.157979, 1.7)); irmX.put("v8", new Irm3PL(0.988294, 1.377501, 0.084828, 1.7)); irmX.put("v9", new Irm3PL(1.248923, 1.614355, 0.181874, 1.7)); irmX.put("v10", new Irm3PL(1.116682, 2.353932, 0.246856, 1.7)); irmX.put("v11", new Irm3PL(0.438171, 3.217965, 0.309243, 1.7)); irmX.put("v12", new Irm3PL(1.082206, 4.441864, 0.192339, 1.7)); double[] step1 = { 0.0, 1.101266, -1.09327 }; irmX.put("v13", new IrmGPCM(0.269994, step1, 1.7)); double[] step2 = { 0.0, 1.739176, 1.526148 }; irmX.put("v14", new IrmGPCM(0.972506, step2, 1.7)); double[] step3 = { 0.0, 5.566958, 1.362356 }; irmX.put("v15", new IrmGPCM(0.378812, step3, 1.7)); double[] step4 = { 0.0, 0.533540, 2.091335, 0.405283 }; irmX.put("v16", new IrmGPCM(0.537706, step4, 1.7)); double[] step5 = { 0.0, 3.440463, 2.235171, 1.62318 }; irmX.put("v17", new IrmGPCM(0.554506, step5, 1.7)); //Form Y irmY.put("v1", new Irm3PL(0.887276, -1.334798, 0.134406, 1.7)); irmY.put("v2", new Irm3PL(1.184412, -1.129004, 0.237765, 1.7)); irmY.put("v3", new Irm3PL(0.609412, -1.464546, 0.151393, 1.7)); irmY.put("v4", new Irm3PL(0.923812, -0.576435, 0.240097, 1.7)); irmY.put("v5", new Irm3PL(0.822776, -0.476357, 0.192369, 1.7)); irmY.put("v6", new Irm3PL(0.707818, -0.235189, 0.189557, 1.7)); irmY.put("v7", new Irm3PL(1.306976, 0.242986, 0.165553, 1.7)); irmY.put("v8", new Irm3PL(1.295471, 0.598029, 0.090557, 1.7)); irmY.put("v9", new Irm3PL(1.366841, 0.923206, 0.172993, 1.7)); irmY.put("v10", new Irm3PL(1.389624, 1.380666, 0.238008, 1.7)); irmY.put("v11", new Irm3PL(0.293806, 2.028070, 0.203448, 1.7)); irmY.put("v12", new Irm3PL(0.885347, 3.152928, 0.195473, 1.7)); double[] step1Y = { 0.0, 0.399117, -1.38735 }; irmY.put("v13", new IrmGPCM(0.346324, step1Y, 1.7)); double[] step2Y = { 0.0, 0.956014, 0.756514 }; irmY.put("v14", new IrmGPCM(1.252012, step2Y, 1.7)); double[] step3Y = { 0.0, 4.676299, 0.975303 }; irmY.put("v15", new IrmGPCM(0.392282, step3Y, 1.7)); double[] step4Y = { 0.0, 0.042549, 1.104823, -0.118440 }; irmY.put("v16", new IrmGPCM(0.660841, step4Y, 1.7)); double[] step5Y = { 0.0, 2.645241, 1.536046, 0.748514 }; irmY.put("v17", new IrmGPCM(0.669612, step5Y, 1.7)); UniformDistributionApproximation uniform = new UniformDistributionApproximation(-3.0, 3.0, 25); HaebaraMethod hb = new HaebaraMethod(irmX, irmY, uniform, uniform, EquatingCriterionType.Q1Q2); hb.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); org.apache.commons.math3.optim.PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(hb), org.apache.commons.math3.optim.nonlinear.scalar.GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] hbCoefficients = optimum.getPoint(); hb.setIntercept(hbCoefficients[0]); hb.setScale(hbCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + hbCoefficients[0] + " A = " + hbCoefficients[1]); assertEquals(" Intercept test", -0.437427, hb.getIntercept(), 1e-4); assertEquals(" Scale test", 0.810364, hb.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.StockingLordMethodTest.java
/** * Item parameters and "true" linking coefficients are from example2 in Kolen's STUIRT program. * */// www. j a va2 s. com @Test public void stockingLordTestMixedFormatPARSCALE() { System.out.println("StockingLordMethod Test 4: STUIRT example 2 with PARSCALE parameters"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //Form X irmX.put("v1", new Irm3PL(0.751335, -0.897391, 0.244001, 1.7)); irmX.put("v2", new Irm3PL(0.955947, -0.811477, 0.242883, 1.7)); irmX.put("v3", new Irm3PL(0.497206, -0.858681, 0.260893, 1.7)); irmX.put("v4", new Irm3PL(0.724000, -0.123911, 0.243497, 1.7)); irmX.put("v5", new Irm3PL(0.865200, 0.205889, 0.319135, 1.7)); irmX.put("v6", new Irm3PL(0.658129, 0.555228, 0.277826, 1.7)); irmX.put("v7", new Irm3PL(1.082118, 0.950549, 0.157979, 1.7)); irmX.put("v8", new Irm3PL(0.988294, 1.377501, 0.084828, 1.7)); irmX.put("v9", new Irm3PL(1.248923, 1.614355, 0.181874, 1.7)); irmX.put("v10", new Irm3PL(1.116682, 2.353932, 0.246856, 1.7)); irmX.put("v11", new Irm3PL(0.438171, 3.217965, 0.309243, 1.7)); irmX.put("v12", new Irm3PL(1.082206, 4.441864, 0.192339, 1.7)); double[] step1 = { 1.097268, -1.097268 }; irmX.put("v13", new IrmGPCM2(0.269994, 0.003998, step1, 1.7)); double[] step2 = { 0.106514, -0.106514 }; irmX.put("v14", new IrmGPCM2(0.972506, 1.632662, step2, 1.7)); double[] step3 = { 2.102301, -2.102301 }; irmX.put("v15", new IrmGPCM2(0.378812, 3.464657, step3, 1.7)); double[] step4 = { -0.476513, 1.081282, -0.604770 }; irmX.put("v16", new IrmGPCM2(0.537706, 1.010053, step4, 1.7)); double[] step5 = { 1.007525, -0.197767, -0.809758 }; irmX.put("v17", new IrmGPCM2(0.554506, 2.432938, step5, 1.7)); //Form Y irmY.put("v1", new Irm3PL(0.887276, -1.334798, 0.134406, 1.7)); irmY.put("v2", new Irm3PL(1.184412, -1.129004, 0.237765, 1.7)); irmY.put("v3", new Irm3PL(0.609412, -1.464546, 0.151393, 1.7)); irmY.put("v4", new Irm3PL(0.923812, -0.576435, 0.240097, 1.7)); irmY.put("v5", new Irm3PL(0.822776, -0.476357, 0.192369, 1.7)); irmY.put("v6", new Irm3PL(0.707818, -0.235189, 0.189557, 1.7)); irmY.put("v7", new Irm3PL(1.306976, 0.242986, 0.165553, 1.7)); irmY.put("v8", new Irm3PL(1.295471, 0.598029, 0.090557, 1.7)); irmY.put("v9", new Irm3PL(1.366841, 0.923206, 0.172993, 1.7)); irmY.put("v10", new Irm3PL(1.389624, 1.380666, 0.238008, 1.7)); irmY.put("v11", new Irm3PL(0.293806, 2.028070, 0.203448, 1.7)); irmY.put("v12", new Irm3PL(0.885347, 3.152928, 0.195473, 1.7)); double[] step1Y = { 0.893232, -0.893232 }; irmY.put("v13", new IrmGPCM2(0.346324, -0.494115, step1Y, 1.7)); double[] step2Y = { 0.099750, -0.099750 }; irmY.put("v14", new IrmGPCM2(1.252012, 0.856264, step2Y, 1.7)); double[] step3Y = { 1.850498, -1.850498 }; irmY.put("v15", new IrmGPCM2(0.392282, 2.825801, step3Y, 1.7)); double[] step4Y = { -0.300428, 0.761846, -0.461417 }; irmY.put("v16", new IrmGPCM2(0.660841, 0.342977, step4Y, 1.7)); double[] step5Y = { 1.001974, -0.107221, -0.894753 }; irmY.put("v17", new IrmGPCM2(0.669612, 1.643267, step5Y, 1.7)); UniformDistributionApproximation uniform = new UniformDistributionApproximation(-3.0, 3.0, 25); StockingLordMethod sl = new StockingLordMethod(irmX, irmY, uniform, uniform, EquatingCriterionType.Q1Q2); sl.setPrecision(6); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(sl), GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] slCoefficients = optimum.getPoint(); sl.setIntercept(slCoefficients[0]); sl.setScale(slCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + slCoefficients[0] + " A = " + slCoefficients[1]); assertEquals(" Intercept test", -0.456487, sl.getIntercept(), 1e-6); assertEquals(" Scale test", 0.815445, sl.getScale(), 1e-6); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.HaebaraMethodTest.java
@Test public void haebaraMethodTestMixedFormat2() { System.out.println("HaebaraMethod Test 4: Mixed format test, symmetric, PARSCALE parameters"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //Form X/*from ww w . j av a 2 s . co m*/ irmX.put("v1", new Irm3PL(0.751335, -0.897391, 0.244001, 1.7)); irmX.put("v2", new Irm3PL(0.955947, -0.811477, 0.242883, 1.7)); irmX.put("v3", new Irm3PL(0.497206, -0.858681, 0.260893, 1.7)); irmX.put("v4", new Irm3PL(0.724000, -0.123911, 0.243497, 1.7)); irmX.put("v5", new Irm3PL(0.865200, 0.205889, 0.319135, 1.7)); irmX.put("v6", new Irm3PL(0.658129, 0.555228, 0.277826, 1.7)); irmX.put("v7", new Irm3PL(1.082118, 0.950549, 0.157979, 1.7)); irmX.put("v8", new Irm3PL(0.988294, 1.377501, 0.084828, 1.7)); irmX.put("v9", new Irm3PL(1.248923, 1.614355, 0.181874, 1.7)); irmX.put("v10", new Irm3PL(1.116682, 2.353932, 0.246856, 1.7)); irmX.put("v11", new Irm3PL(0.438171, 3.217965, 0.309243, 1.7)); irmX.put("v12", new Irm3PL(1.082206, 4.441864, 0.192339, 1.7)); double[] step1 = { 1.097268, -1.097268 }; irmX.put("v13", new IrmGPCM2(0.269994, 0.003998, step1, 1.7)); double[] step2 = { 0.106514, -0.106514 }; irmX.put("v14", new IrmGPCM2(0.972506, 1.632662, step2, 1.7)); double[] step3 = { 2.102301, -2.102301 }; irmX.put("v15", new IrmGPCM2(0.378812, 3.464657, step3, 1.7)); double[] step4 = { -0.476513, 1.081282, -0.604770 }; irmX.put("v16", new IrmGPCM2(0.537706, 1.010053, step4, 1.7)); double[] step5 = { 1.007525, -0.197767, -0.809758 }; irmX.put("v17", new IrmGPCM2(0.554506, 2.432938, step5, 1.7)); //Form Y irmY.put("v1", new Irm3PL(0.887276, -1.334798, 0.134406, 1.7)); irmY.put("v2", new Irm3PL(1.184412, -1.129004, 0.237765, 1.7)); irmY.put("v3", new Irm3PL(0.609412, -1.464546, 0.151393, 1.7)); irmY.put("v4", new Irm3PL(0.923812, -0.576435, 0.240097, 1.7)); irmY.put("v5", new Irm3PL(0.822776, -0.476357, 0.192369, 1.7)); irmY.put("v6", new Irm3PL(0.707818, -0.235189, 0.189557, 1.7)); irmY.put("v7", new Irm3PL(1.306976, 0.242986, 0.165553, 1.7)); irmY.put("v8", new Irm3PL(1.295471, 0.598029, 0.090557, 1.7)); irmY.put("v9", new Irm3PL(1.366841, 0.923206, 0.172993, 1.7)); irmY.put("v10", new Irm3PL(1.389624, 1.380666, 0.238008, 1.7)); irmY.put("v11", new Irm3PL(0.293806, 2.028070, 0.203448, 1.7)); irmY.put("v12", new Irm3PL(0.885347, 3.152928, 0.195473, 1.7)); double[] step1Y = { 0.893232, -0.893232 }; irmY.put("v13", new IrmGPCM2(0.346324, -0.494115, step1Y, 1.7)); double[] step2Y = { 0.099750, -0.099750 }; irmY.put("v14", new IrmGPCM2(1.252012, 0.856264, step2Y, 1.7)); double[] step3Y = { 1.850498, -1.850498 }; irmY.put("v15", new IrmGPCM2(0.392282, 2.825801, step3Y, 1.7)); double[] step4Y = { -0.300428, 0.761846, -0.461417 }; irmY.put("v16", new IrmGPCM2(0.660841, 0.342977, step4Y, 1.7)); double[] step5Y = { 1.001974, -0.107221, -0.894753 }; irmY.put("v17", new IrmGPCM2(0.669612, 1.643267, step5Y, 1.7)); UniformDistributionApproximation uniform = new UniformDistributionApproximation(-3.0, 3.0, 25); HaebaraMethod hb = new HaebaraMethod(irmX, irmY, uniform, uniform, EquatingCriterionType.Q1Q2); hb.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); org.apache.commons.math3.optim.PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(hb), org.apache.commons.math3.optim.nonlinear.scalar.GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] hbCoefficients = optimum.getPoint(); hb.setIntercept(hbCoefficients[0]); hb.setScale(hbCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + hbCoefficients[0] + " A = " + hbCoefficients[1]); assertEquals(" Intercept test", -0.446101, hb.getIntercept(), 1e-4); assertEquals(" Scale test", 0.805049, hb.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.HaebaraMethodTest.java
@Test public void haebaraMethodTestMixedFormat3() { System.out.println("HaebaraMethod Test 5: Mixed format test, symmetric, Graded Response"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //3pl items//from w ww . j a va 2 s.c o m irmX.put("v1", new Irm3PL(1.0755, -1.8758, 0.1240, 1.7)); irmX.put("v2", new Irm3PL(0.6428, -0.9211, 0.1361, 1.7)); irmX.put("v3", new Irm3PL(0.6198, -1.3362, 0.1276, 1.7)); irmX.put("v4", new Irm3PL(0.6835, -1.8967, 0.1619, 1.7)); irmX.put("v5", new Irm3PL(0.9892, -0.6427, 0.2050, 1.7)); irmX.put("v6", new Irm3PL(0.5784, -0.8181, 0.1168, 1.7)); irmX.put("v7", new Irm3PL(0.9822, -0.9897, 0.1053, 1.7)); irmX.put("v8", new Irm3PL(1.6026, -1.2382, 0.1202, 1.7)); irmX.put("v9", new Irm3PL(0.8988, -0.5180, 0.1320, 1.7)); irmX.put("v10", new Irm3PL(1.2525, -0.7164, 0.1493, 1.7)); //gpcm items double[] step1 = { -2.1415, 0.0382, 0.6551 }; irmX.put("v11", new IrmGRM(1.1196, step1, 1.7)); double[] step2 = { -1.7523, -1.0660, 0.3533 }; irmX.put("v12", new IrmGRM(1.2290, step2, 1.7)); double[] step3 = { -2.3126, -1.8816, 0.7757 }; irmX.put("v13", new IrmGRM(0.6405, step3, 1.7)); double[] step4 = { -1.9728, -0.2810, 1.1387 }; irmX.put("v14", new IrmGRM(1.1622, step4, 1.7)); double[] step5 = { -2.2207, -0.8252, 0.9702 }; irmX.put("v15", new IrmGRM(1.2249, step5, 1.7)); //3pl items irmY.put("v1", new Irm3PL(0.7444, -1.5617, 0.1609, 1.7)); irmY.put("v2", new Irm3PL(0.5562, -0.1031, 0.1753, 1.7)); irmY.put("v3", new Irm3PL(0.5262, -1.0676, 0.1602, 1.7)); irmY.put("v4", new Irm3PL(0.6388, -1.3880, 0.1676, 1.7)); irmY.put("v5", new Irm3PL(0.8793, -0.2051, 0.1422, 1.7)); irmY.put("v6", new Irm3PL(0.4105, 0.0555, 0.2120, 1.7)); irmY.put("v7", new Irm3PL(0.7686, -0.3800, 0.2090, 1.7)); irmY.put("v8", new Irm3PL(1.0539, -0.7570, 0.1270, 1.7)); irmY.put("v9", new Irm3PL(0.7400, 0.0667, 0.1543, 1.7)); irmY.put("v10", new Irm3PL(0.7479, 0.0281, 0.1489, 1.7)); //gpcm items double[] step6 = { -1.7786, 0.7177, 1.45011 }; irmY.put("v11", new IrmGRM(0.9171, step6, 1.7)); double[] step7 = { -1.4115, -0.4946, 1.15969 }; irmY.put("v12", new IrmGRM(0.9751, step7, 1.7)); double[] step8 = { -1.8478, -1.4078, 1.51339 }; irmY.put("v13", new IrmGRM(0.5890, step8, 1.7)); double[] step9 = { -1.6151, 0.3002, 2.04728 }; irmY.put("v14", new IrmGRM(0.9804, step9, 1.7)); double[] step10 = { -1.9355, -0.2267, 1.88991 }; irmY.put("v15", new IrmGRM(1.0117, step10, 1.7)); UniformDistributionApproximation uniform = new UniformDistributionApproximation(-3.0, 3.0, 25); HaebaraMethod hb = new HaebaraMethod(irmX, irmY, uniform, uniform, EquatingCriterionType.Q1Q2); hb.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); org.apache.commons.math3.optim.PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(hb), org.apache.commons.math3.optim.nonlinear.scalar.GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] hbCoefficients = optimum.getPoint(); hb.setIntercept(hbCoefficients[0]); hb.setScale(hbCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + hbCoefficients[0] + " A = " + hbCoefficients[1]); assertEquals(" Intercept test", 0.715912, hb.getIntercept(), 1e-4); assertEquals(" Scale test", 1.203554, hb.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.StockingLordMethodTest.java
/** * Item parameter and "true" linking coefficients are based on example 2 in Kolen's STUIRT program. * For polytomous items, the difficulty and threshold parameters were combined to be step parameters * as done with Brad Hanson's GPCM. That is, teh parameters are configured to conform to the "IS" * version of the GPCM as specified in the STUIRT manual. */// www . j a v a 2 s .co m @Test public void stockingLordTestMixedICL() { System.out.println("StockingLordMethod Test 4: STUIRT example 2 with ICL parameters"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //Form X irmX.put("v1", new Irm3PL(0.751335, -0.897391, 0.244001, 1.7)); irmX.put("v2", new Irm3PL(0.955947, -0.811477, 0.242883, 1.7)); irmX.put("v3", new Irm3PL(0.497206, -0.858681, 0.260893, 1.7)); irmX.put("v4", new Irm3PL(0.724000, -0.123911, 0.243497, 1.7)); irmX.put("v5", new Irm3PL(0.865200, 0.205889, 0.319135, 1.7)); irmX.put("v6", new Irm3PL(0.658129, 0.555228, 0.277826, 1.7)); irmX.put("v7", new Irm3PL(1.082118, 0.950549, 0.157979, 1.7)); irmX.put("v8", new Irm3PL(0.988294, 1.377501, 0.084828, 1.7)); irmX.put("v9", new Irm3PL(1.248923, 1.614355, 0.181874, 1.7)); irmX.put("v10", new Irm3PL(1.116682, 2.353932, 0.246856, 1.7)); irmX.put("v11", new Irm3PL(0.438171, 3.217965, 0.309243, 1.7)); irmX.put("v12", new Irm3PL(1.082206, 4.441864, 0.192339, 1.7)); double[] step1 = { 0.0, 1.101266, -1.09327 }; irmX.put("v13", new IrmGPCM(0.269994, step1, 1.7)); double[] step2 = { 0.0, 1.739176, 1.526148 }; irmX.put("v14", new IrmGPCM(0.972506, step2, 1.7)); double[] step3 = { 0.0, 5.566958, 1.362356 }; irmX.put("v15", new IrmGPCM(0.378812, step3, 1.7)); double[] step4 = { 0.0, 0.533540, 2.091335, 0.405283 }; irmX.put("v16", new IrmGPCM(0.537706, step4, 1.7)); double[] step5 = { 0.0, 3.440463, 2.235171, 1.62318 }; irmX.put("v17", new IrmGPCM(0.554506, step5, 1.7)); //Form Y irmY.put("v1", new Irm3PL(0.887276, -1.334798, 0.134406, 1.7)); irmY.put("v2", new Irm3PL(1.184412, -1.129004, 0.237765, 1.7)); irmY.put("v3", new Irm3PL(0.609412, -1.464546, 0.151393, 1.7)); irmY.put("v4", new Irm3PL(0.923812, -0.576435, 0.240097, 1.7)); irmY.put("v5", new Irm3PL(0.822776, -0.476357, 0.192369, 1.7)); irmY.put("v6", new Irm3PL(0.707818, -0.235189, 0.189557, 1.7)); irmY.put("v7", new Irm3PL(1.306976, 0.242986, 0.165553, 1.7)); irmY.put("v8", new Irm3PL(1.295471, 0.598029, 0.090557, 1.7)); irmY.put("v9", new Irm3PL(1.366841, 0.923206, 0.172993, 1.7)); irmY.put("v10", new Irm3PL(1.389624, 1.380666, 0.238008, 1.7)); irmY.put("v11", new Irm3PL(0.293806, 2.028070, 0.203448, 1.7)); irmY.put("v12", new Irm3PL(0.885347, 3.152928, 0.195473, 1.7)); double[] step1Y = { 0.0, 0.399117, -1.38735 }; irmY.put("v13", new IrmGPCM(0.346324, step1Y, 1.7)); double[] step2Y = { 0.0, 0.956014, 0.756514 }; irmY.put("v14", new IrmGPCM(1.252012, step2Y, 1.7)); double[] step3Y = { 0.0, 4.676299, 0.975303 }; irmY.put("v15", new IrmGPCM(0.392282, step3Y, 1.7)); double[] step4Y = { 0.0, 0.042549, 1.104823, -0.118440 }; irmY.put("v16", new IrmGPCM(0.660841, step4Y, 1.7)); double[] step5Y = { 0.0, 2.645241, 1.536046, 0.748514 }; irmY.put("v17", new IrmGPCM(0.669612, step5Y, 1.7)); UniformDistributionApproximation uniform = new UniformDistributionApproximation(-3.0, 3.0, 25); StockingLordMethod sl = new StockingLordMethod(irmX, irmY, uniform, uniform, EquatingCriterionType.Q1Q2); sl.setPrecision(6); double[] startValues = { 0, 1 }; //Run test with UNCMIN optimizer DefaultUncminOptimizer optimizer = new DefaultUncminOptimizer(); double[] param1 = null; double[] param2 = null; double f = 0; try { optimizer.minimize(sl, startValues); param1 = optimizer.getParameters(); f = optimizer.getFunctionValue(); sl.setIntercept(param1[0]); sl.setScale(param1[1]); } catch (UncminException ex) { ex.printStackTrace(); } //Check UNCMIN values against results from STUIRT. System.out.println(" UNCMIN Optimization"); System.out.println(" Iterations: "); System.out.println(" fmin: " + f); System.out.println(" B = " + sl.getIntercept() + " A = " + sl.getScale()); assertEquals(" Intercept test", -0.452240, sl.getIntercept(), 1e-6); assertEquals(" Scale test", 0.820927, sl.getScale(), 1e-6); //Check BOBYQA values against STUIRT results. int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer2 = new MultiStartMultivariateOptimizer(underlying, 10, generator); PointValuePair optimum = optimizer2.optimize(new MaxEval(1000), new ObjectiveFunction(sl), GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); param2 = optimum.getPoint(); sl.setIntercept(param2[0]); sl.setScale(param2[1]); System.out.println(); System.out.println(" BOBYQA Optimization"); System.out.println(" Iterations: " + optimizer2.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + param2[0] + " A = " + param2[1]); assertEquals(" Intercept test", -0.452240, sl.getIntercept(), 1e-6); assertEquals(" Scale test", 0.820927, sl.getScale(), 1e-6); //Compare results from each optimizer assertEquals(" Intercept test", param1[0], param2[0], 1e-6); assertEquals(" Scale test", param1[1], param2[1], 1e-6); }
From source file:com.itemanalysis.psychometrics.irt.equating.HaebaraMethodTest.java
@Test public void stockingLordTestMixedFormat4() { System.out.println("StockingLordMethod Test 5: Mixed format test, symmetric, Graded Response 2"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //3pl items/* w w w . jav a 2 s.co m*/ irmX.put("v1", new Irm3PL(1.0755, -1.8758, 0.1240, 1.7)); irmX.put("v2", new Irm3PL(0.6428, -0.9211, 0.1361, 1.7)); irmX.put("v3", new Irm3PL(0.6198, -1.3362, 0.1276, 1.7)); irmX.put("v4", new Irm3PL(0.6835, -1.8967, 0.1619, 1.7)); irmX.put("v5", new Irm3PL(0.9892, -0.6427, 0.2050, 1.7)); irmX.put("v6", new Irm3PL(0.5784, -0.8181, 0.1168, 1.7)); irmX.put("v7", new Irm3PL(0.9822, -0.9897, 0.1053, 1.7)); irmX.put("v8", new Irm3PL(1.6026, -1.2382, 0.1202, 1.7)); irmX.put("v9", new Irm3PL(0.8988, -0.5180, 0.1320, 1.7)); irmX.put("v10", new Irm3PL(1.2525, -0.7164, 0.1493, 1.7)); //gpcm items double[] step1 = { -2.1415, 0.0382, 0.6551 }; irmX.put("v11", new IrmGRM(1.1196, step1, 1.7)); double[] step2 = { -1.7523, -1.0660, 0.3533 }; irmX.put("v12", new IrmGRM(1.2290, step2, 1.7)); double[] step3 = { -2.3126, -1.8816, 0.7757 }; irmX.put("v13", new IrmGRM(0.6405, step3, 1.7)); double[] step4 = { -1.9728, -0.2810, 1.1387 }; irmX.put("v14", new IrmGRM(1.1622, step4, 1.7)); double[] step5 = { -2.2207, -0.8252, 0.9702 }; irmX.put("v15", new IrmGRM(1.2249, step5, 1.7)); //3pl items irmY.put("v1", new Irm3PL(0.7444, -1.5617, 0.1609, 1.7)); irmY.put("v2", new Irm3PL(0.5562, -0.1031, 0.1753, 1.7)); irmY.put("v3", new Irm3PL(0.5262, -1.0676, 0.1602, 1.7)); irmY.put("v4", new Irm3PL(0.6388, -1.3880, 0.1676, 1.7)); irmY.put("v5", new Irm3PL(0.8793, -0.2051, 0.1422, 1.7)); irmY.put("v6", new Irm3PL(0.4105, 0.0555, 0.2120, 1.7)); irmY.put("v7", new Irm3PL(0.7686, -0.3800, 0.2090, 1.7)); irmY.put("v8", new Irm3PL(1.0539, -0.7570, 0.1270, 1.7)); irmY.put("v9", new Irm3PL(0.7400, 0.0667, 0.1543, 1.7)); irmY.put("v10", new Irm3PL(0.7479, 0.0281, 0.1489, 1.7)); //gpcm items double[] step6 = { -1.7786, 0.7177, 1.45011 }; irmY.put("v11", new IrmGRM(0.9171, step6, 1.7)); double[] step7 = { -1.4115, -0.4946, 1.15969 }; irmY.put("v12", new IrmGRM(0.9751, step7, 1.7)); double[] step8 = { -1.8478, -1.4078, 1.51339 }; irmY.put("v13", new IrmGRM(0.5890, step8, 1.7)); double[] step9 = { -1.6151, 0.3002, 2.04728 }; irmY.put("v14", new IrmGRM(0.9804, step9, 1.7)); double[] step10 = { -1.9355, -0.2267, 1.88991 }; irmY.put("v15", new IrmGRM(1.0117, step10, 1.7)); UserSuppliedDistributionApproximation distX = new UserSuppliedDistributionApproximation(points, xDensity); UserSuppliedDistributionApproximation distY = new UserSuppliedDistributionApproximation(points, yDensity); HaebaraMethod hb = new HaebaraMethod(irmX, irmY, distX, distY, EquatingCriterionType.Q1Q2); hb.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); org.apache.commons.math3.optim.PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(hb), org.apache.commons.math3.optim.nonlinear.scalar.GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] hbCoefficients = optimum.getPoint(); hb.setIntercept(hbCoefficients[0]); hb.setScale(hbCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + hbCoefficients[0] + " A = " + hbCoefficients[1]); assertEquals(" Intercept test", 0.726026, hb.getIntercept(), 1e-4); assertEquals(" Scale test", 1.203780, hb.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.StockingLordMethodTest.java
@Test public void stockingLordTestMixedFormatGradedResponse() { System.out.println("StockingLordMethod Test 5: Mixed format test, symmetric, Graded Response"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //3pl items/*from ww w . jav a 2 s .co m*/ irmX.put("v1", new Irm3PL(1.0755, -1.8758, 0.1240, 1.7)); irmX.put("v2", new Irm3PL(0.6428, -0.9211, 0.1361, 1.7)); irmX.put("v3", new Irm3PL(0.6198, -1.3362, 0.1276, 1.7)); irmX.put("v4", new Irm3PL(0.6835, -1.8967, 0.1619, 1.7)); irmX.put("v5", new Irm3PL(0.9892, -0.6427, 0.2050, 1.7)); irmX.put("v6", new Irm3PL(0.5784, -0.8181, 0.1168, 1.7)); irmX.put("v7", new Irm3PL(0.9822, -0.9897, 0.1053, 1.7)); irmX.put("v8", new Irm3PL(1.6026, -1.2382, 0.1202, 1.7)); irmX.put("v9", new Irm3PL(0.8988, -0.5180, 0.1320, 1.7)); irmX.put("v10", new Irm3PL(1.2525, -0.7164, 0.1493, 1.7)); //gpcm items double[] step1 = { -2.1415, 0.0382, 0.6551 }; irmX.put("v11", new IrmGRM(1.1196, step1, 1.7)); double[] step2 = { -1.7523, -1.0660, 0.3533 }; irmX.put("v12", new IrmGRM(1.2290, step2, 1.7)); double[] step3 = { -2.3126, -1.8816, 0.7757 }; irmX.put("v13", new IrmGRM(0.6405, step3, 1.7)); double[] step4 = { -1.9728, -0.2810, 1.1387 }; irmX.put("v14", new IrmGRM(1.1622, step4, 1.7)); double[] step5 = { -2.2207, -0.8252, 0.9702 }; irmX.put("v15", new IrmGRM(1.2249, step5, 1.7)); //3pl items irmY.put("v1", new Irm3PL(0.7444, -1.5617, 0.1609, 1.7)); irmY.put("v2", new Irm3PL(0.5562, -0.1031, 0.1753, 1.7)); irmY.put("v3", new Irm3PL(0.5262, -1.0676, 0.1602, 1.7)); irmY.put("v4", new Irm3PL(0.6388, -1.3880, 0.1676, 1.7)); irmY.put("v5", new Irm3PL(0.8793, -0.2051, 0.1422, 1.7)); irmY.put("v6", new Irm3PL(0.4105, 0.0555, 0.2120, 1.7)); irmY.put("v7", new Irm3PL(0.7686, -0.3800, 0.2090, 1.7)); irmY.put("v8", new Irm3PL(1.0539, -0.7570, 0.1270, 1.7)); irmY.put("v9", new Irm3PL(0.7400, 0.0667, 0.1543, 1.7)); irmY.put("v10", new Irm3PL(0.7479, 0.0281, 0.1489, 1.7)); //gpcm items double[] step6 = { -1.7786, 0.7177, 1.45011 }; irmY.put("v11", new IrmGRM(0.9171, step6, 1.7)); double[] step7 = { -1.4115, -0.4946, 1.15969 }; irmY.put("v12", new IrmGRM(0.9751, step7, 1.7)); double[] step8 = { -1.8478, -1.4078, 1.51339 }; irmY.put("v13", new IrmGRM(0.5890, step8, 1.7)); double[] step9 = { -1.6151, 0.3002, 2.04728 }; irmY.put("v14", new IrmGRM(0.9804, step9, 1.7)); double[] step10 = { -1.9355, -0.2267, 1.88991 }; irmY.put("v15", new IrmGRM(1.0117, step10, 1.7)); UniformDistributionApproximation uniform = new UniformDistributionApproximation(-3.0, 3.0, 25); StockingLordMethod sl = new StockingLordMethod(irmX, irmY, uniform, uniform, EquatingCriterionType.Q1Q2); sl.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(sl), GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] slCoefficients = optimum.getPoint(); sl.setIntercept(slCoefficients[0]); sl.setScale(slCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + slCoefficients[0] + " A = " + slCoefficients[1]); assertEquals(" Intercept test", 0.730924, sl.getIntercept(), 1e-4); assertEquals(" Scale test", 1.218034, sl.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.HaebaraMethodTest.java
@Test public void stockingLordTestMixedFormat5() { System.out.println("StockingLordMethod Test 6: Mixed format test, backwards, Graded Response 2"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //3pl items//from w w w . j a va 2 s . com irmX.put("v1", new Irm3PL(1.0755, -1.8758, 0.1240, 1.7)); irmX.put("v2", new Irm3PL(0.6428, -0.9211, 0.1361, 1.7)); irmX.put("v3", new Irm3PL(0.6198, -1.3362, 0.1276, 1.7)); irmX.put("v4", new Irm3PL(0.6835, -1.8967, 0.1619, 1.7)); irmX.put("v5", new Irm3PL(0.9892, -0.6427, 0.2050, 1.7)); irmX.put("v6", new Irm3PL(0.5784, -0.8181, 0.1168, 1.7)); irmX.put("v7", new Irm3PL(0.9822, -0.9897, 0.1053, 1.7)); irmX.put("v8", new Irm3PL(1.6026, -1.2382, 0.1202, 1.7)); irmX.put("v9", new Irm3PL(0.8988, -0.5180, 0.1320, 1.7)); irmX.put("v10", new Irm3PL(1.2525, -0.7164, 0.1493, 1.7)); //gpcm items double[] step1 = { -2.1415, 0.0382, 0.6551 }; irmX.put("v11", new IrmGRM(1.1196, step1, 1.7)); double[] step2 = { -1.7523, -1.0660, 0.3533 }; irmX.put("v12", new IrmGRM(1.2290, step2, 1.7)); double[] step3 = { -2.3126, -1.8816, 0.7757 }; irmX.put("v13", new IrmGRM(0.6405, step3, 1.7)); double[] step4 = { -1.9728, -0.2810, 1.1387 }; irmX.put("v14", new IrmGRM(1.1622, step4, 1.7)); double[] step5 = { -2.2207, -0.8252, 0.9702 }; irmX.put("v15", new IrmGRM(1.2249, step5, 1.7)); //3pl items irmY.put("v1", new Irm3PL(0.7444, -1.5617, 0.1609, 1.7)); irmY.put("v2", new Irm3PL(0.5562, -0.1031, 0.1753, 1.7)); irmY.put("v3", new Irm3PL(0.5262, -1.0676, 0.1602, 1.7)); irmY.put("v4", new Irm3PL(0.6388, -1.3880, 0.1676, 1.7)); irmY.put("v5", new Irm3PL(0.8793, -0.2051, 0.1422, 1.7)); irmY.put("v6", new Irm3PL(0.4105, 0.0555, 0.2120, 1.7)); irmY.put("v7", new Irm3PL(0.7686, -0.3800, 0.2090, 1.7)); irmY.put("v8", new Irm3PL(1.0539, -0.7570, 0.1270, 1.7)); irmY.put("v9", new Irm3PL(0.7400, 0.0667, 0.1543, 1.7)); irmY.put("v10", new Irm3PL(0.7479, 0.0281, 0.1489, 1.7)); //gpcm items double[] step6 = { -1.7786, 0.7177, 1.45011 }; irmY.put("v11", new IrmGRM(0.9171, step6, 1.7)); double[] step7 = { -1.4115, -0.4946, 1.15969 }; irmY.put("v12", new IrmGRM(0.9751, step7, 1.7)); double[] step8 = { -1.8478, -1.4078, 1.51339 }; irmY.put("v13", new IrmGRM(0.5890, step8, 1.7)); double[] step9 = { -1.6151, 0.3002, 2.04728 }; irmY.put("v14", new IrmGRM(0.9804, step9, 1.7)); double[] step10 = { -1.9355, -0.2267, 1.88991 }; irmY.put("v15", new IrmGRM(1.0117, step10, 1.7)); UserSuppliedDistributionApproximation distX = new UserSuppliedDistributionApproximation(points, xDensity); UserSuppliedDistributionApproximation distY = new UserSuppliedDistributionApproximation(points, yDensity); HaebaraMethod hb = new HaebaraMethod(irmX, irmY, distX, distY, EquatingCriterionType.Q1); hb.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); org.apache.commons.math3.optim.PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(hb), org.apache.commons.math3.optim.nonlinear.scalar.GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] hbCoefficients = optimum.getPoint(); hb.setIntercept(hbCoefficients[0]); hb.setScale(hbCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + hbCoefficients[0] + " A = " + hbCoefficients[1]); assertEquals(" Intercept test", 0.731176, hb.getIntercept(), 1e-4); assertEquals(" Scale test", 1.209901, hb.getScale(), 1e-4); System.out.println(); }