@@ -20,7 +20,7 @@ void testConstantFunction() {
20
20
@ Test
21
21
void testLinearFunction () {
22
22
// Integral of f(x) = x from 0 to 1 is 0.5
23
- Function <Double , Double > linear = x -> x ;
23
+ Function <Double , Double > linear = Function . identity () ;
24
24
double result = MonteCarloIntegration .approximate (linear , 0 , 1 , 10000 );
25
25
assertEquals (0.5 , result , EPSILON );
26
26
}
@@ -43,7 +43,7 @@ void testLargeSampleSize() {
43
43
44
44
@ Test
45
45
void testReproducibility () {
46
- Function <Double , Double > linear = x -> x ;
46
+ Function <Double , Double > linear = Function . identity () ;
47
47
double result1 = MonteCarloIntegration .approximate (linear , 0 , 1 , 10000 , 42L );
48
48
double result2 = MonteCarloIntegration .approximate (linear , 0 , 1 , 10000 , 42L );
49
49
assertEquals (result1 , result2 , 0.0 ); // Exactly equal
@@ -52,7 +52,7 @@ void testReproducibility() {
52
52
@ Test
53
53
void testNegativeInterval () {
54
54
// Integral of f(x) = x from -1 to 1 is 0
55
- Function <Double , Double > linear = x -> x ;
55
+ Function <Double , Double > linear = Function . identity () ;
56
56
double result = MonteCarloIntegration .approximate (linear , -1 , 1 , 10000 );
57
57
assertEquals (0.0 , result , EPSILON );
58
58
}
0 commit comments