### Question:
IrmBinaryModel { public double[] gradient(double theta, double[] iparam, int k, double D){ double[] deriv = new double[numberOfParameters]; double a = iparam[0]; double b = iparam[1]; double c = iparam[2]; double u = iparam[3]; double e1 = a * D; double e2 = theta - b; double e4 = Math.exp(-(e1 * e2)); double e5 = 1 + e4; double e6 = e5*e5; double e7 = 1/e5; double e8 = u - c; deriv[0] = D * e4 * e2 * e8/e6; deriv[1] = -(e1 * e4 * e8/e6); deriv[2] = 1.0 - e7; deriv[3] = e7; if(k==0){ deriv[0] = -deriv[0]; deriv[1] = -deriv[1]; deriv[2] = -deriv[2]; deriv[3] = -deriv[3]; } deriv[0] *= fixedMask[0]; deriv[1] *= fixedMask[1]; deriv[2] *= fixedMask[2]; deriv[3] *= fixedMask[3]; return deriv; } IrmBinaryModel(double discrimination, double difficulty, double guessing, double slipping);  IrmBinaryModel(double discrimination, double difficulty, double guessing);  IrmBinaryModel(double discrimination, double difficulty);  IrmBinaryModel(double difficulty); double probability(double theta, double[] iparam, int response); double probability(double theta, int response); double expectedValue(double theta); double cumulativeProbability(double theta, int category); double[] gradient(double theta, double[] iparam, int k, double D); double[] gradient(double theta, int k); double[][] hessian(double theta, double[] iparam); double[][] hessian(double theta); double derivTheta(double theta); double deriv2Theta(double theta); double itemInformationAt(double theta); void setScalingConstant(double D); void scale(double intercept, double slope); void setFixedMask(double[] fixedMask); int getNumberOfFreeParameters();  }### Answer:
@Test public void gradientTest(){ System.out.println("4PL Gradient"); IrmBinaryModel irm4 = new IrmBinaryModel(0.8, -1.0, 0.2, 0.95); System.out.println(Arrays.toString(irm4.gradient(0, 1))); Irm4PL pl4 = new Irm4PL(0.8, -1.0, 0.2, 0.95, 1.0); System.out.println(Arrays.toString(pl4.gradient(0, 1))); System.out.println(); System.out.println("3PL Gradient"); IrmBinaryModel irm3 = new IrmBinaryModel(0.8, -1.0, 0.2); System.out.println(Arrays.toString(irm3.gradient(0, 1))); Irm3PL pl3 = new Irm3PL(0.8, -1.0, 0.2, 1.0); System.out.println(Arrays.toString(pl3.gradient(0, 1))); System.out.println(); System.out.println("2PL Gradient"); IrmBinaryModel irm2 = new IrmBinaryModel(0.8, -1.0); System.out.println(Arrays.toString(irm2.gradient(0, 1))); Irm3PL pl2 = new Irm3PL(0.8, -1.0, 1.0); System.out.println(Arrays.toString(pl2.gradient(0, 1))); System.out.println(); System.out.println("1PL Gradient"); IrmBinaryModel irm1 = new IrmBinaryModel(-1.0); System.out.println(Arrays.toString(irm1.gradient(0, 1))); Irm3PL pl1 = new Irm3PL(-1.0, 1.0); System.out.println(Arrays.toString(pl1.gradient(0, 1))); }