Task Description: Implement Geometric Distribution Sampling Functionality
Functionality to Implement:
Enhance the GeometricDistribution class by adding the method sampleWithMean(double mean, SourceOfRandomness random). This method should calculate and return a random sample from a geometric distribution defined by the specified mean.
Input/Output Requirements:
Input:
mean: A double representing the mean of the geometric distribution. It must be greater than 0.
random: An instance of SourceOfRandomness, which is used to generate random numbers.
Output:
The method should return an integer that represents a sample from the geometric distribution corresponding to the provided mean. The output must adhere to the properties of the geometric distribution, where the mean is equal to 1/p (with p being the probability of success).
Notes:
Ensure that the implementation handles edge cases, such as invalid mean values (e.g., mean <= 0).
The existing sample(double p, SourceOfRandomness random) method should be used to derive probabilities where necessary.
Location for Implementation:
Implement the new method in the GeometricDistribution class located in the /app/ directory.