DiscreteModel { public DiscreteModelEvaluation process(int[] y, Matrix X) { m_y = y; m_x = X; double[] c = initialize(); llFn fn = new llFn(this); if (getMinimizer().minimize(fn, new DiscreteModelEvaluation(this, new DataBlock(c)))) { return (DiscreteModelEvaluation) getMinimizer().getResult(); } else { return null; } } DiscreteModel(ICumulativeDistributionFunction fn); DiscreteModelEvaluation process(int[] y, Matrix X); double[] probabilities(DataBlock b); double loglikelihood(DataBlock b); ICumulativeDistributionFunction getCumulativeDistributionFunction(); double dloglikelihood(DataBlock b, int i); double[] loglikelihoodGradient(DataBlock b); Matrix logLikelihoodHessian(DataBlock b); int[] getY(); Matrix getX(); IFunctionMinimizer getMinimizer(); void setMinimizer(IFunctionMinimizer minimizer);  }
@Test public void demoSomeMethod() { int n=10000; int[] y=new int[n]; for (int i=0; i<y.length; ++i){ y[i]=i<n/2 ? 0 :1; } Matrix M =new Matrix(n, 100); M.randomize(); M.add(-.5); M.column(0).set(1); DiscreteModel model=new DiscreteModel(new Probit()); DiscreteModelEvaluation rslt = model.process(y, M); IReadDataBlock parameters = rslt.getParameters(); System.out.println(parameters); System.out.println(new DataBlock(rslt.gradient())); model=new DiscreteModel(new Logit()); rslt = model.process(y, M); parameters = rslt.getParameters(); System.out.println(parameters); System.out.println(new DataBlock(rslt.gradient())); }