`generate_data.py` for processing and fitting statistical distributions to data.

'distributions.py' to create new dists to fit

'analysis_data.ipynb" notebook for data analysis
This commit is contained in:
2026-04-10 15:01:07 -03:00
parent aacfe3f977
commit 9aa97fc3d4
8 changed files with 973 additions and 3 deletions

View File

@@ -0,0 +1,43 @@
from scipy.stats import rv_continuous
from scipy.special import gamma, kv, gammaln
from scipy.stats._distn_infrastructure import _ShapeInfo
import numpy as np
import pandas as pd
class k_gen(rv_continuous):
"""K distribution for radar clutter modeling.
The probability density function is::
f(x; nu, b) = 2/Gamma(nu) * b^((nu+1)/2) * x^((nu-1)/2) * K_{nu-1}(2*sqrt(b*x))
for x >= 0, where K_{nu-1} is the modified Bessel function of the second
kind of order nu-1, nu > 0 is the shape parameter and b > 0 is the rate
parameter.
"""
def _shape_info(self):
return [_ShapeInfo("nu", domain=(0, np.inf), inclusive=(False, True)),
_ShapeInfo("b", domain=(0, np.inf), inclusive=(False, True))]
def _argcheck(self, nu, b):
return (nu > 0) & (b > 0)
def _pdf(self, x, nu, b):
# k.pdf(x, nu, b) = 2/Gamma(nu) * b^((nu+1)/2) * x^((nu-1)/2) * K_{nu-1}(2*sqrt(b*x))
return np.exp(self._logpdf(x, nu, b))
def _logpdf(self, x, nu, b):
return (
np.log(2.0)
- gammaln(nu)
+ (nu + 1) / 2.0 * np.log(b)
+ (nu - 1) / 2.0 * np.log(x)
+ np.log(kv(nu - 1, 2.0 * np.sqrt(b * x)))
)
k_dist = k_gen(a=0.0, name="k_distribution", shapes="nu, b")