graphinglib.FitFromGaussian#

class graphinglib.FitFromGaussian(curve_to_be_fit: Curve | Scatter, label: str | None = None, guesses: ArrayLike | None = None, color: str = 'default', line_width: int | Literal['default'] = 'default', line_style: str = 'default')[source]#

Create a curve fit (continuous Curve) from an existing Curve object using a gaussian fit.

Fits a gaussian function of the form \(f(x) = A e^{-\frac{(x - \mu)^2}{2 \sigma^2}}\) to the given curve. All standard Curve attributes and methods are available.

Parameters:
curve_to_be_fitCurve or Scatter

The object to be fit.

labelstr, optional

Label to be displayed in the legend.

guessesArrayLike, optional

Initial guesses for the parameters of the fit. Order is amplitude (A), mean (mu), standard deviation (sigma).

colorstr

Color of the curve. Default depends on the figure_style configuration.

line_widthint

Line width of the curve. Default depends on the figure_style configuration.

line_stylestr

Line style of the curve. Default depends on the figure_style configuration.

Attributes:
amplitudefloat

Amplitude of the gaussian function.

meanfloat

Mean of the gaussian function.

standard_deviationfloat

Standard deviation of the gaussian function.

Warning

The standard_deviation attribute doesn’t represent the standard deviation of the fit parameters as it does in the other fit classes. Instead, it represents the standard deviation of the gaussian function (it is one of parameters of the fit). The standard deviation of the fit parameters can be found in the standard_deviation_of_fit_params attribute.

cov_matrixnp.ndarray

Covariance matrix of the parameters of the fit.

standard_deviation_of_fit_paramsnp.ndarray

Standard deviation of the parameters of the fit.

functionCallable

Gaussian function with the parameters of the fit.

Methods

__init__(curve_to_be_fit[, label, guesses, ...])

Create a curve fit (continuous Curve) from an existing Curve object using a gaussian fit.

add_error_curves([y_error, ...])

Adds error curves to the Curve.

add_errorbars([x_error, y_error, cap_width, ...])

Adds errorbars to the Curve.

copy()

Returns a deep copy of the Curve.

create_derivative_curve([label, color, ...])

Creates a new curve which is the derivative of the original curve.

create_integral_curve([initial_value, ...])

Creates a new curve which is the integral of the original curve.

create_intersection_points(other[, labels, ...])

Creates the intersection Points between two curves.

create_normal_curve(x[, label, color, ...])

Creates a new curve which is the normal to the original curve at a given x value.

create_point_at_x(x[, label, color, ...])

Gets the point on the curve at a given x value.

create_points_at_y(y[, interpolation_kind, ...])

Creates the Points on the curve at a given y value.

create_slice_x(x1, x2[, label, color, ...])

Creates a slice of the curve between two x values.

create_slice_y(y1, y2[, label, color, ...])

Creates a slice of the curve between two y values.

create_tangent_curve(x[, label, color, ...])

Creates a new curve which is the tangent to the original curve at a given x value.

from_function(func, x_min, x_max[, label, ...])

Creates a Curve from a function and a range of x values.

get_Rsquared()

Calculates the \(R^2\) value of the fit curve.

get_arc_length_between(x1, x2)

Calculates the arc length of the curve between two x values.

get_area_between(x1, x2[, fill_between, ...])

Calculates the area between the curve and the x axis between two x values.

get_coordinates_at_x(x)

Gets the coordinates of the curve at a given x value.

get_coordinates_at_y(y[, interpolation_method])

Gets the coordinates of the curve at a given y value.

get_intersection_coordinates(other)

Calculates the coordinates of the intersection points between two curves.

get_residuals()

Calculates the residuals of the fit curve.

get_slope_at(x)

Calculates the slope of the curve at a given x value.

show_residual_curves([sigma_multiplier, ...])

Displays two curves "sigma_multiplier" standard deviations above and below the fit curve.