Giter Site home page Giter Site logo

Add K distribution about distfit HOT 4 CLOSED

erdogant avatar erdogant commented on May 26, 2024
Add K distribution

from distfit.

Comments (4)

erdogant avatar erdogant commented on May 26, 2024

thanks! But with with K-distribution you refer to the compound of two gammas? Which library would you recommend to look at?

from distfit.

ShaofengZou avatar ShaofengZou commented on May 26, 2024

Sorry, I haven't found any suitable library about K-distribution. And i am a little confused about the definition about K distritbution.
In some paper, the K distritbuion is defined as $p(x)=\frac{2 b}{\Gamma(v)}\left(\frac{b x}{2}\right)^{v} K_{v-1}(b x)$. [1][2]
While in other paper, the K distribution id defined as $f_{X}(x ; b, v)=\frac{2 b}{\Gamma(v)}(\sqrt{b x})^{v-1} K_{v-1}(2 \sqrt{b x})$. [3][4]

I have code for estimating the parameters of the K distribution of the first formula using the estimation of moments.

Here is the code:
image

from scipy.special import gamma
from scipy.special import kv as besselk
def k_distribution(x, v, mu):
    f_k = 2 / (mu*gamma(v)) * (x / (2*mu))**v * besselk(v-1,x / mu)
    return f_k

def k_estimate(data):
    x_2= np.mean(data**2)
    x_4 = np.mean(data**4)
    v = (x_4/(2*(x_2)**2) - 1 )**(-1)
    mu = 0.5*np.sqrt(x_2/v)
    return v, mu

Here is the reference:
[1] Rangaswamy M, Weiner D, Ozturk A. Computer generation of correlated non-Gaussian radar clutter[J]. IEEE Transactions on Aerospace and Electronic Systems, 1995, 31(1): 106-116.
[2] Lamont-Smith T. Translation to the normal distribution for radar clutter[J]. IEE Proceedings-Radar, Sonar and Navigation, 2000, 147(1): 17-22.
[3] https://en.wikipedia.org/wiki/K-distribution
[4] Redding N J. Estimating the parameters of the K distribution in the intensity domain[J]. 1999.

Hope can help you a little and solve my confusion.

Thanks!

from distfit.

erdogant avatar erdogant commented on May 26, 2024

It took a while but I created a first implementation of the K-distribution based on your input.
You can test the new functionality as following:

Install from github source:
install git+https://github.com/erdogant/distfit

Example:

import numpy as np
from distfit import distfit
X = np.random.normal(0, 2, 1000)
y = [-8, -6, 0, 1, 2, 3, 4, 5, 6]
dist = distfit(distr=['k','t','expon', 't', 'gamma', 'lognorm'])
results = dist.fit_transform(X)

dist.plot()
dist.plot_summary()

In order to test this, it would be great to have data for which we already know it is K-distributed.

from distfit.

erdogant avatar erdogant commented on May 26, 2024

Closing this one. Let me know if something is missing or needs to be changed regarding the "k" distribution.

from distfit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.