modelbase2 0.2.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
modelbase2/__init__.py CHANGED
@@ -53,6 +53,7 @@ __all__ = [
53
53
  "make_protocol",
54
54
  "mc",
55
55
  "mca",
56
+ "nnarchitectures",
56
57
  "plot",
57
58
  "sbml",
58
59
  "steady_state",
@@ -70,7 +71,17 @@ import pandas as pd
70
71
  if TYPE_CHECKING:
71
72
  from modelbase2.types import ArrayLike
72
73
 
73
- from . import distributions, experimental, fit, mc, mca, plot, sbml, surrogates
74
+ from . import (
75
+ distributions,
76
+ experimental,
77
+ fit,
78
+ mc,
79
+ mca,
80
+ nnarchitectures,
81
+ plot,
82
+ sbml,
83
+ surrogates,
84
+ )
74
85
  from .integrators import DefaultIntegrator, Scipy
75
86
  from .label_map import LabelMapper
76
87
  from .linear_label_map import LinearLabelMapper
@@ -7,6 +7,7 @@ Classes:
7
7
  Distribution (Protocol): Base protocol for all distribution classes
8
8
  Beta: Beta distribution for parameters bounded between 0 and 1
9
9
  Uniform: Uniform distribution for parameters with simple bounds
10
+ LogUniform: LogUniform distribution for parameters with simple bounds
10
11
  Normal: Normal (Gaussian) distribution for unbounded parameters
11
12
  LogNormal: Log-normal distribution for strictly positive parameters
12
13
  Skewnorm: Skewed normal distribution for asymmetric parameter distributions
@@ -35,6 +36,7 @@ __all__ = [
35
36
  "Distribution",
36
37
  "GaussianKde",
37
38
  "LogNormal",
39
+ "LogUniform",
38
40
  "Normal",
39
41
  "RNG",
40
42
  "Skewnorm",
@@ -121,6 +123,37 @@ class Uniform:
121
123
  return rng.uniform(self.lower_bound, self.upper_bound, num)
122
124
 
123
125
 
126
+ @dataclass
127
+ class LogUniform:
128
+ """LogUniform distribution for parameters with simple bounds.
129
+
130
+ Args:
131
+ lower_bound: Minimum value
132
+ upper_bound: Maximum value
133
+
134
+ """
135
+
136
+ lower_bound: float
137
+ upper_bound: float
138
+
139
+ def sample(self, num: int, rng: np.random.Generator | None = None) -> Array:
140
+ """Generate random samples from the loguniform distribution.
141
+
142
+ Args:
143
+ num: Number of samples to generate
144
+ rng: Random number generator
145
+
146
+ """
147
+ if rng is None:
148
+ rng = RNG
149
+ return cast(
150
+ Array,
151
+ stats.loguniform.rvs(
152
+ self.lower_bound, self.upper_bound, size=num, random_state=rng
153
+ ),
154
+ )
155
+
156
+
124
157
  @dataclass
125
158
  class Normal:
126
159
  """Normal (Gaussian) distribution for unbounded parameters.
@@ -7,11 +7,13 @@ from __future__ import annotations
7
7
 
8
8
  from .codegen import generate_model_code_py, generate_modelbase_code
9
9
  from .diff import model_diff
10
+ from .symbolic import model_fn_to_sympy
10
11
  from .tex import to_tex
11
12
 
12
13
  __all__ = [
13
14
  "generate_model_code_py",
14
15
  "generate_modelbase_code",
15
16
  "model_diff",
17
+ "model_fn_to_sympy",
16
18
  "to_tex",
17
19
  ]