[
https://issues.apache.org/jira/browse/STATISTICS-31?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17380794#comment-17380794
]
Alex Herbert edited comment on STATISTICS-31 at 7/14/21, 6:31 PM:
------------------------------------------------------------------
Support can be added to the ContinuousDistribution interface using a default
method:
{code:java}
/**
* For a random variable {@code X} whose values are distributed according
* to this distribution, this method returns {@code P(X >= x)}.
* In other words, this method represents the complementary cumulative
distribution
* function for this distribution, also known as the survival function or
* reliability function.
*
* @param x Point at which the complementary CDF is evaluated.
* @return the probability that a random variable with this
* distribution takes a value more than or equal to {@code x}.
*/
default double survivalProbability(double x) {
return 1 - cumulativeProbability(x);
}
{code}
A similar method can be added to DiscreteDistribution interface too.
Distributions where a more accurate result can be obtained as the CDF -> 1 can
override the method. These would exploit the availability of far more double
values for the result as it approaches 0, rather than the default
implementation which is limited to a minimum of 2^-53 (i.e. 1.0 -
nextDown(1.0)).
Is this what you are suggesting?
was (Author: alexherbert):
Support can be added to the ContinuousDistribution interface using a default
method:
{code:java}
/**
* For a random variable {@code X} whose values are distributed according
* to this distribution, this method returns {@code P(X >= x)}.
* In other words, this method represents the complementary cumulative
distribution
* function for this distribution, also known as the survival function or
* reliability function.
*
* @param x Point at which the CDF is evaluated.
* @return the probability that a random variable with this
* distribution takes a value more than or equal to {@code x}.
*/
default double survivalProbability(double x) {
return 1 - cumulativeProbability(x);
}
{code}
A similar method can be added to DiscreteDistribution interface too.
Distributions where a more accurate result can be obtained as the CDF -> 1 can
override the method. These would exploit the availability of far more double
values for the result as it approaches 0, rather than the default
implementation which is limited to a minimum of 2^-53 (i.e. 1.0 -
nextDown(1.0)).
Is this what you are suggesting?
> Add survival probability function to continuous distributions
> -------------------------------------------------------------
>
> Key: STATISTICS-31
> URL: https://issues.apache.org/jira/browse/STATISTICS-31
> Project: Apache Commons Statistics
> Issue Type: New Feature
> Reporter: Benjamin W Trent
> Priority: Major
>
> It is useful to know the [survival
> function|[https://en.wikipedia.org/wiki/Survival_function]] of a number given
> a continuous distribution.
> While this can be approximated with
> {noformat}
> 1 - cdf(x){noformat}
> , there is an opportunity for greater accuracy in certain distributions.
>
> A good example of this is the gamma distribution. The survival function for
> that distribution would probably look similar to:
>
> ```java
> @Override
> public double survivalProbability(double x) {
> if (x <= SUPPORT_LO)
> { return 1; }
> else if (x >= SUPPORT_HI)
> { return 0; }
> return RegularizedGamma.Q.value(shape, x / scale);
> }
> ```
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)