Skip to content

Commit

Permalink
fdfit: add docstring to Parameter
Browse files Browse the repository at this point in the history
without these, the properties don't show up in the docs
  • Loading branch information
JoepVanlier committed Aug 8, 2024
1 parent a8283cb commit b9dd3c4
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions lumicks/pylake/fitting/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@


class Parameter:
"""A single model parameter, usually part of a :class:`Params` dictionary.
Examples
--------
::
import lumicks.pylake as lk
fit = lk.FdFit(lk.ewlc_odijk_distance("my_model"))
print(fit.params) # Prints the model parameters
parameter = fit["my_model/Lc"] = 5 # parameter is of the type `Parameter` here.
# You can extract and/or modify fitting bounds
lower_bound = parameter.lower_bound
# Or read out the fitting error after the model has been fitted.
print(f"fitting error Lc: {parameter.stderr}")
"""

__slots__ = [
"value",
"lower_bound",
Expand Down Expand Up @@ -43,13 +62,44 @@ def __init__(
Unit of the parameter
"""
self.value = value
"""Parameter value."""

self.lower_bound = lower_bound
"""Lower bound used when fitting."""

self.upper_bound = upper_bound
"""Upper bound used when fitting."""

self.fixed = fixed
"""Parameter is held fixed during fitting."""

self.shared = shared
"""Parameter is shared between all sub-models.
Some parameters are not expected to be different between sub-models.
"""

self.unit = unit
"""Unit of this parameter."""

self.profile = None
"""Profile likelihood result.
Profile likelihood estimates confidence intervals for the model parameters. These
confidence intervals can be used to assess whether a parameter can reliably be estimated
from the data. See also: :meth:`~lumicks.pylake.FdFit.profile_likelihood()`.
"""

self.stderr = None
"""Standard error of this parameter.
Standard errors are calculated after fitting the model. These asymptotic errors are based
on the fitted parameter values and model sensitivities.
.. note::
These errors may be inaccurate in the presence of model non-identifiability. See
also: :meth:`~lumicks.pylake.FdFit.profile_likelihood()`."""

def __float__(self):
return float(self.value)
Expand Down Expand Up @@ -89,8 +139,7 @@ def ci(self, percentile=0.95, dof=1):


class Params:
"""
Model parameters.
"""A dictionary of :class:`Parameter`.
Examples
--------
Expand All @@ -100,8 +149,8 @@ class Params:
fit = lk.FdFit(lk.ewlc_odijk_distance("my_model"))
print(fit.params) # Prints the model parameters
fit["test_parameter"].value = 5 # Set parameter test_parameter to 5
fit["fix_me"].fixed = True # Fix parameter fix_me (do not fit)
fit["my_model/Lc"].value = 5 # Set parameter my_model/Lc to 5
fit["my_model/Lc"].fixed = True # Fix parameter my_model/Lc (do not fit)
# Copy parameters from another Parameters into this one.
parameters.update_params(other_parameters)
Expand Down

0 comments on commit b9dd3c4

Please sign in to comment.