distribution_functions¶
shortfx.fxNumeric.distribution_functions
¶
Probability Distributions Module.
Provides probability density/mass functions, cumulative distribution functions,
and their inverses for common distributions. Requires scipy for most
functions; a graceful ImportError is raised when scipy is absent.
Key Features
- Normal (Gaussian) distribution
- Student's t-distribution
- Binomial distribution
- Poisson distribution
- Chi-squared distribution
- F-distribution
- Exponential distribution
Example
from shortfx.fxNumeric.distribution_functions import norm_dist round(norm_dist(0, 0, 1, cumulative=True), 4) 0.5
Functions¶
beta_dist(x: float, alpha: float, beta: float, cumulative: bool = True) -> float
¶
Beta distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate (0 ≤ x ≤ 1). |
required |
alpha
|
float
|
Alpha parameter (> 0). |
required |
beta
|
float
|
Beta parameter (> 0). |
required |
cumulative
|
bool
|
True for CDF, False for PDF. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If x not in [0,1] or parameters ≤ 0. |
Example
round(beta_dist(0.4, 2, 5), 6) 0.580096
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
beta_inv(probability: float, alpha: float, beta: float) -> float
¶
Inverse of the Beta cumulative distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
Probability (0 < p < 1). |
required |
alpha
|
float
|
Alpha parameter (> 0). |
required |
beta
|
float
|
Beta parameter (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Value x such that P(X ≤ x) = probability. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If probability not in (0,1) or parameters ≤ 0. |
Example
round(beta_inv(0.5, 2, 5), 6) 0.264653
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
binom_dist(number_s: int, trials: int, probability_s: float, cumulative: bool = True) -> float
¶
Binomial distribution PMF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number_s
|
int
|
Number of successes. |
required |
trials
|
int
|
Number of independent trials. |
required |
probability_s
|
float
|
Probability of success on each trial. |
required |
cumulative
|
bool
|
If True return CDF, else PMF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not of expected types. |
ValueError
|
If parameters are out of valid ranges. |
Example
round(binom_dist(3, 10, 0.5, cumulative=False), 6) 0.117188
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
binom_dist_range(trials: int, probability_s: float, number_s: int, number_s2: int | None = None) -> float
¶
Probability of a binomial trial result between two values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trials
|
int
|
Number of trials. |
required |
probability_s
|
float
|
Probability of success per trial. |
required |
number_s
|
int
|
Lower bound of successes. |
required |
number_s2
|
int | None
|
Upper bound of successes (defaults to number_s). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Probability of successes in [number_s, number_s2]. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If parameters out of range. |
Example
round(binom_dist_range(10, 0.5, 3, 7), 6) 0.890625
Complexity: O(k) where k = number_s2 - number_s
Source code in shortfx/fxNumeric/distribution_functions.py
binom_inv(trials: int, probability_s: float, alpha: float) -> int
¶
Inverse binomial distribution (CRITBINOM).
Description
Returns the smallest value k such that P(X ≤ k) ≥ alpha for a binomial distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trials
|
int
|
Number of trials. |
required |
probability_s
|
float
|
Probability of success per trial. |
required |
alpha
|
float
|
Criterion probability (0 < alpha < 1). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Smallest k satisfying the criterion. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If parameters out of range. |
Example
binom_inv(6, 0.5, 0.75) 4
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
chisq_dist(x: float, deg_freedom: int, cumulative: bool = True) -> float
¶
Chi-squared distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value at which to evaluate (must be >= 0). |
required |
deg_freedom
|
int
|
Degrees of freedom (must be >= 1). |
required |
cumulative
|
bool
|
If True return CDF, else PDF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not of expected types. |
ValueError
|
If parameters are out of valid ranges. |
Example
round(chisq_dist(3.84, 1, cumulative=True), 4) 0.9499
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
chisq_dist_rt(x: float, deg_freedom: int) -> float
¶
Right-tailed Chi-squared distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate (≥ 0). |
required |
deg_freedom
|
int
|
Degrees of freedom (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
P(X² > x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If x < 0 or deg_freedom ≤ 0. |
Example
round(chisq_dist_rt(18.307, 10), 6) 0.05
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
chisq_inv(probability: float, deg_freedom: int) -> float
¶
Inverse of the chi-squared cumulative distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
A probability in (0, 1). |
required |
deg_freedom
|
int
|
Degrees of freedom (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The chi-squared value. |
Example
round(chisq_inv(0.95, 1), 4) 3.8415
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
chisq_inv_rt(probability: float, deg_freedom: int) -> float
¶
Inverse of the right-tailed Chi-squared distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
Right-tail probability (0 < p < 1). |
required |
deg_freedom
|
int
|
Degrees of freedom (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Value x such that P(X² > x) = probability. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If probability not in (0,1) or deg_freedom ≤ 0. |
Example
round(chisq_inv_rt(0.05, 10), 4) 18.307
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
expon_dist(x: float, lambda_: float, cumulative: bool = True) -> float
¶
Exponential distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value at which to evaluate (must be >= 0). |
required |
lambda_
|
float
|
Rate parameter (must be > 0). |
required |
cumulative
|
bool
|
If True return CDF, else PDF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If parameters are out of valid ranges. |
Example
round(expon_dist(1, 1, cumulative=True), 6) 0.632121
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
f_dist(x: float, deg_freedom1: int, deg_freedom2: int, cumulative: bool = True) -> float
¶
F-distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value at which to evaluate (must be >= 0). |
required |
deg_freedom1
|
int
|
Numerator degrees of freedom (>= 1). |
required |
deg_freedom2
|
int
|
Denominator degrees of freedom (>= 1). |
required |
cumulative
|
bool
|
If True return CDF, else PDF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not of expected types. |
ValueError
|
If parameters are out of valid ranges. |
Example
round(f_dist(3.0, 5, 10, cumulative=True), 4) 0.9269
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
f_dist_rt(x: float, deg_freedom1: int, deg_freedom2: int) -> float
¶
Right-tailed F-distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate (≥ 0). |
required |
deg_freedom1
|
int
|
Numerator degrees of freedom (> 0). |
required |
deg_freedom2
|
int
|
Denominator degrees of freedom (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
P(F > x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If x < 0 or degrees of freedom ≤ 0. |
Example
round(f_dist_rt(3.5, 5, 10), 6) 0.044525
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
f_inv(probability: float, deg_freedom1: int, deg_freedom2: int) -> float
¶
Inverse of the F cumulative distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
A probability in (0, 1). |
required |
deg_freedom1
|
int
|
Numerator degrees of freedom (>= 1). |
required |
deg_freedom2
|
int
|
Denominator degrees of freedom (>= 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The F-value. |
Example
round(f_inv(0.95, 5, 10), 4) 3.3258
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
f_inv_rt(probability: float, deg_freedom1: int, deg_freedom2: int) -> float
¶
Inverse of the right-tailed F-distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
Right-tail probability (0 < p < 1). |
required |
deg_freedom1
|
int
|
Numerator degrees of freedom (> 0). |
required |
deg_freedom2
|
int
|
Denominator degrees of freedom (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Value x such that P(F > x) = probability. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If probability not in (0,1) or degrees of freedom ≤ 0. |
Example
round(f_inv_rt(0.05, 5, 10), 6) 3.325835
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
gamma_dist(x: float, alpha: float, beta: float, cumulative: bool = True) -> float
¶
Gamma distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate (≥ 0). |
required |
alpha
|
float
|
Shape parameter (> 0). |
required |
beta
|
float
|
Scale parameter (> 0). |
required |
cumulative
|
bool
|
True for CDF, False for PDF. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If x < 0 or parameters ≤ 0. |
Example
round(gamma_dist(2, 3, 1), 6) 0.323324
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
gamma_inv(probability: float, alpha: float, beta: float) -> float
¶
Inverse of the Gamma cumulative distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
Probability (0 < p < 1). |
required |
alpha
|
float
|
Shape parameter (> 0). |
required |
beta
|
float
|
Scale parameter (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Value x such that P(X ≤ x) = probability. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If probability not in (0,1) or parameters ≤ 0. |
Example
round(gamma_inv(0.5, 3, 1), 6) 2.674051
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
gauss(z: float) -> float
¶
Probability that a standard normal variable falls between 0 and z.
Description
Returns P(0 < Z < z) for the standard normal distribution. Equivalent to Excel GAUSS. Computed as Φ(z) − 0.5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
float
|
The z-score value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The probability in the range (0, z). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If z is not a number. |
Example
round(gauss(2), 6) 0.47725 round(gauss(0), 6) 0.0
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
hypgeom_dist(sample_s: int, number_sample: int, population_s: int, number_pop: int, cumulative: bool = True) -> float
¶
Hypergeometric distribution PMF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_s
|
int
|
Number of successes in the sample. |
required |
number_sample
|
int
|
Size of the sample. |
required |
population_s
|
int
|
Number of successes in the population. |
required |
number_pop
|
int
|
Population size. |
required |
cumulative
|
bool
|
True for CDF, False for PMF. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not integers. |
ValueError
|
If parameters out of range. |
Example
round(hypgeom_dist(1, 4, 8, 20), 6) 0.213995
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
lognorm_dist(x: float, mean: float, standard_dev: float, cumulative: bool = True) -> float
¶
Log-normal distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate (> 0). |
required |
mean
|
float
|
Mean of ln(x). |
required |
standard_dev
|
float
|
Standard deviation of ln(x) (> 0). |
required |
cumulative
|
bool
|
True for CDF, False for PDF. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If x ≤ 0 or standard_dev ≤ 0. |
Example
round(lognorm_dist(4, 3.5, 1.2), 6) 0.01761
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
lognorm_inv(probability: float, mean: float, standard_dev: float) -> float
¶
Inverse of the Log-normal cumulative distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
Probability (0 < p < 1). |
required |
mean
|
float
|
Mean of ln(x). |
required |
standard_dev
|
float
|
Standard deviation of ln(x) (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Value x such that P(X ≤ x) = probability. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If probability not in (0,1) or standard_dev ≤ 0. |
Example
round(lognorm_inv(0.5, 3.5, 1.2), 6) 33.11545
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
negbinom_dist(number_f: int, number_s: int, probability_s: float, cumulative: bool = True) -> float
¶
Negative binomial distribution PMF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number_f
|
int
|
Number of failures before the number_s-th success. |
required |
number_s
|
int
|
Number of successes (> 0). |
required |
probability_s
|
float
|
Probability of success per trial (0 < p ≤ 1). |
required |
cumulative
|
bool
|
True for CDF, False for PMF. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If parameters out of range. |
Example
round(negbinom_dist(3, 5, 0.4), 6) 0.174286
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
norm_dist(x: float, mean: float = 0.0, std_dev: float = 1.0, cumulative: bool = True) -> float
¶
Normal (Gaussian) distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value at which to evaluate. |
required |
mean
|
float
|
Distribution mean. Default 0. |
0.0
|
std_dev
|
float
|
Standard deviation (must be > 0). Default 1. |
1.0
|
cumulative
|
bool
|
If True return CDF, else PDF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If std_dev <= 0. |
Example
round(norm_dist(0, 0, 1, cumulative=True), 4) 0.5 round(norm_dist(0, 0, 1, cumulative=False), 6) 0.398942
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
norm_inv(probability: float, mean: float = 0.0, std_dev: float = 1.0) -> float
¶
Inverse of the normal cumulative distribution (quantile function).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
A probability in (0, 1). |
required |
mean
|
float
|
Distribution mean. Default 0. |
0.0
|
std_dev
|
float
|
Standard deviation (must be > 0). Default 1. |
1.0
|
Returns:
| Type | Description |
|---|---|
float
|
The value x such that P(X <= x) = probability. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If probability is not in (0, 1) or std_dev <= 0. |
Example
round(norm_inv(0.975, 0, 1), 4) 1.96
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
norm_s_dist(z: float, cumulative: bool = True) -> float
¶
Standard normal distribution (mean=0, std=1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
float
|
The z-value. |
required |
cumulative
|
bool
|
If True return CDF, else PDF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Example
round(norm_s_dist(1.96, cumulative=True), 4) 0.975
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
norm_s_inv(probability: float) -> float
¶
Inverse of the standard normal cumulative distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
A probability in (0, 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The z-value. |
Example
round(norm_s_inv(0.975), 4) 1.96
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
phi(x: float) -> float
¶
Standard normal probability density function φ(x).
Description
Returns the value of the standard normal PDF at x. Equivalent to Excel PHI. Formula: (1/√(2π)) · e^(−x²/2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The point to evaluate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The PDF value at x. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not a number. |
Example
round(phi(0), 6) 0.398942 round(phi(1), 6) 0.241971
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
poisson_dist(x: int, mean: float, cumulative: bool = True) -> float
¶
Poisson distribution PMF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
Number of events. |
required |
mean
|
float
|
Expected number of events (lambda, must be > 0). |
required |
cumulative
|
bool
|
If True return CDF, else PMF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not of expected types. |
ValueError
|
If parameters are out of valid ranges. |
Example
round(poisson_dist(2, 5, cumulative=False), 6) 0.084224
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
t_dist(x: float, deg_freedom: int, cumulative: bool = True) -> float
¶
Student's t-distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value at which to evaluate. |
required |
deg_freedom
|
int
|
Degrees of freedom (must be >= 1). |
required |
cumulative
|
bool
|
If True return CDF, else PDF. |
True
|
Returns:
| Type | Description |
|---|---|
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not of expected types. |
ValueError
|
If deg_freedom < 1. |
Example
round(t_dist(0, 10, cumulative=True), 4) 0.5
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
t_dist_2t(x: float, deg_freedom: int) -> float
¶
Two-tailed Student's t-distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate (must be ≥ 0). |
required |
deg_freedom
|
int
|
Degrees of freedom (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
P(|T| > x) = 2 * P(T > |x|). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If x < 0 or deg_freedom ≤ 0. |
Example
round(t_dist_2t(1.96, 10), 6) 0.078634
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
t_dist_rt(x: float, deg_freedom: int) -> float
¶
Right-tailed Student's t-distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate. |
required |
deg_freedom
|
int
|
Degrees of freedom (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
P(T > x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If deg_freedom ≤ 0. |
Example
round(t_dist_rt(1.96, 10), 6) 0.039317
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
t_inv(probability: float, deg_freedom: int) -> float
¶
Inverse of the Student's t cumulative distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
A probability in (0, 1). |
required |
deg_freedom
|
int
|
Degrees of freedom (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The t-value. |
Example
round(t_inv(0.975, 10), 4) 2.2281
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
t_inv_2t(probability: float, deg_freedom: int) -> float
¶
Inverse of two-tailed Student's t-distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
Two-tailed probability (0 < p < 1). |
required |
deg_freedom
|
int
|
Degrees of freedom (> 0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Value t such that P(|T| > t) = probability. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not valid types. |
ValueError
|
If probability not in (0,1) or deg_freedom ≤ 0. |
Example
round(t_inv_2t(0.05, 10), 6) 2.228139
Complexity: O(1)
Source code in shortfx/fxNumeric/distribution_functions.py
weibull_dist(x: float, alpha: float, beta: float, cumulative: bool = True) -> float
¶
Weibull distribution PDF or CDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value at which to evaluate (≥ 0). |
required |
alpha
|
float
|
Shape parameter (> 0). |
required |
beta
|
float
|
Scale parameter (> 0). |
required |
cumulative
|
bool
|
True for CDF, False for PDF. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Probability value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If x < 0 or parameters ≤ 0. |
Example
round(weibull_dist(2, 3, 1), 6) 0.999877
Complexity: O(1)