toArray(), 0.01 ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The CLTV can be calculated using the migration model')] public function testMigrationModel() : void { // The first element in the migration model result is the CLTV self::assertEqualsWithDelta( [[231.08], [57.29], [21.01], [0.0]], Metrics::migrationModel( 0.1, [0.5, 0.2, 0.1, 0], [100, 0, 0, 0] )->toArray(), 0.1 ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The migration model can be used in order to determin which buying/none-buying customer group should receive a mailing')] public function testMailingSuccessEstimation() : void { self::assertEqualsWithDelta( [[49.4], [2.69], [-1.98], [0.0]], Metrics::calculateMailingSuccessEstimation( 0.2, [0.3, 0.2, 0.05, 0], [36, -4, -4, 0] )->toArray(), 0.1 ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The probability of a customer buying can be calculated based on his previous purchase behavior')] public function testCustomerActiveProbability() : void { $purchases = 10; $periods = 36; // months self::assertEqualsWithDelta(0.017, Metrics::customerActiveProbability($purchases, $periods, 24), 0.001); self::assertEqualsWithDelta(1.0, Metrics::customerActiveProbability($purchases, $periods, 36), 0.001); } }