### Question:
SumToOne { public double[] inverseTransform(double[] modelParms) { ArgChecker.isTrue(modelParms.length == _n, "length of modelParms is {}, but must be {} ", modelParms.length, _n); double[] res = new double[_n - 1]; double[] cum = new double[_n + 1]; double sum = 0.0; for (int i = 0; i < _n; i++) { sum += modelParms[i]; cum[i + 1] = sum; } ArgChecker.isTrue(Math.abs(sum - 1.0) < TOL, "sum of elements is {}. Must be 1.0", sum); cal(cum, 1.0, 0, _n, 0, res); for (int i = 0; i < _n - 1; i++) { res[i] = Math.asin(Math.sqrt(res[i])); } return res; } SumToOne(int n); double[] transform(double[] fitParms); DoubleArray transform(DoubleArray fitParms); double[] inverseTransform(double[] modelParms); DoubleArray inverseTransform(DoubleArray modelParms); double[][] jacobian(double[] fitParms); DoubleMatrix jacobian(DoubleArray fitParms);  }### Answer:
@Test public void inverseTransformTest() { for (int n = 2; n < 13; n++) { double[] theta = new double[n - 1]; for (int j = 0; j < n - 1; j++) { theta[j] = RANDOM.nextDouble() * Math.PI / 2; } SumToOne trans = new SumToOne(n); DoubleArray w = trans.transform(DoubleArray.copyOf(theta)); DoubleArray theta2 = trans.inverseTransform(w); for (int j = 0; j < n - 1; j++) { assertThat(theta[j]).as("element " + j + ", of vector length " + n).isCloseTo(theta2.get(j), offset(1e-9)); } } }