Routines to compute the background from an array of timestamps. This module
is normally imported as bg
when fretbursts is imported.
The important functions are exp_fit()
and exp_cdf_fit()
that
provide two (fast) algorithms to estimate the background without binning.
These functions are not usually called directly but passed to
Data.calc_bg()
to compute the background of a measurement.
See also exp_hist_fit()
for background estimation using an histogram fit.
fretbursts.background.
exp_fit
(ph, tail_min_us=None, clk_p=1.25e-08, error_metrics=None)¶Return a background rate using the MLE of mean waiting-times.
Compute the background rate, selecting waiting-times (delays) larger than a minimum threshold.
This function performs a Maximum Likelihood (ML) fit. For exponentially-distributed waiting-times this is the empirical mean.
Parameters: |
|
---|---|
Returns: | 2-Tuple – Estimated background rate in cps, and a “quality of fit” index (the lower the better) according to the chosen metric. If error_metrics==None, the returned “quality of fit” is None. |
See also
fretbursts.background.
exp_cdf_fit
(ph, tail_min_us=None, clk_p=1.25e-08, error_metrics=None)¶Return a background rate fitting the empirical CDF of waiting-times.
Compute the background rate, selecting waiting-times (delays) larger than a minimum threshold.
This function performs a least square fit of an exponential Cumulative Distribution Function (CDF) to the empirical CDF of waiting-times.
Parameters: |
|
---|---|
Returns: | 2-Tuple – Estimated background rate in cps, and a “quality of fit” index (the lower the better) according to the chosen metric. If error_metrics==None, the returned “quality of fit” is None. |
See also
fretbursts.background.
exp_hist_fit
(ph, tail_min_us, binw=5e-05, clk_p=1.25e-08, weights='hist_counts', error_metrics=None)¶Compute background rate with WLS histogram fit of waiting-times.
Compute the background rate, selecting waiting-times (delays) larger than a minimum threshold.
This function performs a Weighed Least Squares (WLS) fit of the histogram of waiting times to an exponential decay.
Parameters: |
|
---|---|
Returns: | 2-Tuple – Estimated background rate in cps, and a “quality of fit” index (the lower the better) according to the chosen metric. If error_metrics==None, the returned “quality of fit” is None. |
See also
Generic functions to fit exponential populations.
These functions can be used directly, or, in a typical FRETBursts workflow they are passed to higher level methods.
See also:
fretbursts.fit.exp_fitting.
expon_fit
(s, s_min=0, offset=0.5, calc_residuals=True)¶Fit sample s
to an exponential distribution using the ML estimator.
This function computes the rate (Lambda) using the maximum likelihood (ML) estimator of the mean waiting-time (Tau), that for an exponentially distributed sample is the sample-mean.
Parameters: |
|
---|---|
Returns: | A 4-tuple of the fitted rate (1/life-time), residuals array, residuals x-axis array, sample size after threshold. |
fretbursts.fit.exp_fitting.
expon_fit_cdf
(s, s_min=0, offset=0.5, calc_residuals=True)¶Fit of an exponential model to the empirical CDF of s
.
This function computes the rate (Lambda) fitting a line (linear regression) to the log of the empirical CDF.
Parameters: |
|
---|---|
Returns: | A 4-tuple of the fitted rate (1/life-time), residuals array, residuals x-axis array, sample size after threshold. |
fretbursts.fit.exp_fitting.
expon_fit_hist
(s, bins, s_min=0, weights=None, offset=0.5, calc_residuals=True)¶Fit of an exponential model to the histogram of s
using least squares.
Parameters: |
|
---|---|
Returns: | A 4-tuple of the fitted rate (1/life-time), residuals array, residuals x-axis array, sample size after threshold. |
fretbursts.fit.exp_fitting.
get_ecdf
(s, offset=0.5)¶Return arrays (x, y) for the empirical CDF curve of sample s
.
See the code for more info (is a one-liner!).
Parameters: |
|
---|---|
Returns: | (x, y) (tuple of arrays) – the x and y values of the empirical CDF |
fretbursts.fit.exp_fitting.
get_residuals
(s, tau_fit, offset=0.5)¶Returns residuals of sample s
CDF vs an exponential CDF.
Parameters: |
|
---|---|
Returns: | residuals (array) – residuals of empirical CDF compared with analytical
CDF with time constant |