From a480f4712f5e7cbcb86a46cc31c594c478d86ef1 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 16 Aug 2024 04:09:29 +0200 Subject: [PATCH] added dice roll --- Math/Stochastic/Distribution/GeometricDistribution.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Math/Stochastic/Distribution/GeometricDistribution.php b/Math/Stochastic/Distribution/GeometricDistribution.php index df96ff874..fa5b8a7a4 100755 --- a/Math/Stochastic/Distribution/GeometricDistribution.php +++ b/Math/Stochastic/Distribution/GeometricDistribution.php @@ -27,6 +27,8 @@ final class GeometricDistribution /** * Constructor. * + * Example: dice roll + * * @since 1.0.0 * @codeCoverageIgnore */ @@ -34,6 +36,14 @@ final class GeometricDistribution { } + /** + * How often to roll to get a specific value with at least percent chance + */ + public static function getHowOften(float $p, float $percent) : float + { + return log(1.0 - $percent) / log(1 - $p); + } + /** * Get probability mass function. *