Skip to main content

Fit a Lognormal + Power law distribution to data

Project description

PDF_Fit

A code to fit the LN+PL or LN+2PL form to the density PDF of star forming regions. To use this:

pip install pdffit

Once you have installed, you can use the following sample script -

from fitter import *
import numpy as np


sample_data = np.load('./sample_data.npz')

#xdata and ydata are just two arrays. 
xdata = sample_data['arr_0']
ydata = sample_data['arr_1']
sink = float(sample_data['arr_2'])

params = Params(s_cut_off = sink)

p0 = [1.7, 1.6, 0.8, 7.1]
PLPLresult = PLPLFit(xdata, ydata, p0, params, use_K21=True)

p0 = [1.85, 1.57]
PLresult = PLFit(xdata, ydata, p0, params)

print (PLresult.sigma_err, PLresult.alpha_err, PLPLresult.sigma_err, PLPLresult.sb)
#To know more about how to access the result: help(Result)

In case you want to dig deeper or just use the function for plotting:

from LNPLPL_functions import *
from LNPL_functions import *

or whichever way you wish to import the modules and the functions within them.

To get help on any function:

help(function_name)

If you're on the pypi page, please checkout the github version to get the sample data if you need.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdffit-0.1.tar.gz (125.7 kB view hashes)

Uploaded Source

Built Distribution

pdffit-0.1-py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page