### Question:
FilterCoefficients { protected void bilinearTransform(double samplingFrequency) throws BadFilterParametersException { int D = aCoefficients.length - 1; int N = bCoefficients.length - 1 ; int M = Math.max(D, N); int Dp = M; int Np = M; double[] bprime = new double[Np + 1]; double[] aprime = new double[Dp + 1]; double value; int i, j, k, l; for (j = 0; j <= Np; j++) { value = 0.0; for (i = 0; i <= N; i++) for (k = 0; k <= i; k++) for (l = 0; l <= M - i; l++) if (k + l == j) value += SpecialMath.combinations(i, k) * SpecialMath.combinations(M - i, l) * bCoefficients[N - i] * Math.pow(2.0 * samplingFrequency, i) * Math.pow(-1.0, k); bprime[j] = value; } for (j = 0; j <= Dp; j++) { value = 0.0; for (i = 0; i <= D; i++) for (k = 0; k <= i; k++) for (l = 0; l <= M - i; l++) if (k + l == j) value += SpecialMath.combinations(i, k) * SpecialMath.combinations(M - i, l) * aCoefficients[D - i] * Math.pow(2.0 * samplingFrequency, i) * Math.pow(-1.0, k); aprime[j] = value; } aCoefficients = aprime; bCoefficients = bprime; normalize(); } 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 testBilinearTransform() throws BadFilterParametersException { double[] b; double[] a; FilterCoefficients coeffs; double[] pythonB; double[] pythonA; b = new double[] {5.0, 6.0, 7.0}; a = new double[] {1.0, 2.0, 3.0, 4.0}; coeffs = new FilterCoefficients(b, a); pythonB = new double[] { 0.04959992, -0.04839636, -0.04957248, 0.0484238 }; pythonA = new double[] { 1. , -2.95959636, 2.92041588, -0.96078816 }; coeffs.bilinearTransform(50.0); assertEquals(new FilterCoefficients(pythonB, pythonA), coeffs, 1e-4); b = new double[] {1.0000000, 0.0000000, 15.9999925}; a = new double[] {1.0000000, 7.7980768, 15.9999925}; pythonB = new double[] {5.06390694e-01, -2.37370693e-07, 5.06390694e-01}; pythonA = new double[] {1.00000000e+00, -2.37370693e-07, 1.27813880e-02}; coeffs = new FilterCoefficients(b, a); coeffs.print(); coeffs.bilinearTransform(2.0); assertEquals(new FilterCoefficients(pythonB, pythonA), coeffs, 1e-4); coeffs.print(); }