### Question:
FilterCoefficients { protected void normalize() throws BadFilterParametersException { int i; i = 0; while (i < aCoefficients.length && aCoefficients[i] == 0) i++; int firstNonZero = i; double[] newACoefficients = new double[aCoefficients.length - firstNonZero]; for (i = 0; i < newACoefficients.length; i++) newACoefficients[i] = aCoefficients[firstNonZero + i]; aCoefficients = newACoefficients; double x = 1.0 / aCoefficients[0]; for (i = 0; i < bCoefficients.length; i++) bCoefficients[i] = bCoefficients[i] * x; for (i = 0; i < aCoefficients.length; i++) aCoefficients[i] = aCoefficients[i] * x; if (Math.abs(bCoefficients[0]) <= 1e-8) { i = 0; while (i < bCoefficients.length && Math.abs(bCoefficients[i]) <= 1e-8) i++; int firstNotCloseToZero = i; double[] newBCoefficients = new double[bCoefficients.length - firstNotCloseToZero]; for (i = 0; i < newBCoefficients.length; i++) newBCoefficients[i] = bCoefficients[firstNotCloseToZero + i]; bCoefficients = newBCoefficients; throw new BadFilterParametersException("Badly conditioned filter coefficients (numerator): the results may be meaningless"); } } FilterCoefficients(double[] bCoefficients, double[] aCoefficients); int getFilterOrder(); int getNumberOfCoefficients(); double[] getACoefficients(); double[] getBCoefficients(); @Override boolean equals(Object o); @Override int hashCode(); void print(); @Override String toString();  }### Answer:
@Test public void testNormalize() throws BadFilterParametersException { FilterCoefficients coeffs = new FilterCoefficients(new double[] {0.1, 0.2, 0.3}, new double[] {0.7, 0.5, 0.3}); coeffs.normalize(); assertEquals(new double[] {0.14285714, 0.28571429, 0.42857143}, coeffs.getBCoefficients(), 1e-7); assertEquals(new double[] {1.0, 0.71428571, 0.42857143}, coeffs.getACoefficients(), 1e-7); coeffs = new FilterCoefficients(new double[] {0.2, 0.3, 0.4}, new double[] {0.5, 0.3, 0.8, 0.1}); coeffs.normalize(); assertEquals(new double[] {0.4, 0.6, 0.8}, coeffs.getBCoefficients(), 1e-7); assertEquals(new double[] {1. , 0.6, 1.6, 0.2}, coeffs.getACoefficients(), 1e-7); }