sim-tools 1.1.0__tar.gz → 1.2.0__tar.gz
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.
- {sim_tools-1.1.0 → sim_tools-1.2.0}/PKG-INFO +1 -1
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/__init__.py +1 -1
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/distributions.py +29 -11
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/time_dependent.py +4 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/.gitignore +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/LICENSE +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/README.md +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/pyproject.toml +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/_validation.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/data/nspp_example1.csv +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/datasets.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/output_analysis.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/ovs/__init__.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/ovs/evaluation.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/ovs/fixed_budget.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/ovs/indifference_zone.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/ovs/toy_models.py +0 -0
- {sim_tools-1.1.0 → sim_tools-1.2.0}/sim_tools/trace.py +0 -0
|
@@ -601,7 +601,12 @@ class DistributionRegistry:
|
|
|
601
601
|
|
|
602
602
|
# Copy params and inject the random seed.
|
|
603
603
|
params = dist_config["params"].copy()
|
|
604
|
-
|
|
604
|
+
|
|
605
|
+
# Only inject random seed if class constructor accepts it
|
|
606
|
+
distribution_class = cls.get(dist_config["class_name"])
|
|
607
|
+
sig = inspect.signature(distribution_class.__init__)
|
|
608
|
+
if "random_seed" in sig.parameters:
|
|
609
|
+
params["random_seed"] = seed
|
|
605
610
|
|
|
606
611
|
# Instantiate and return the distribution object.
|
|
607
612
|
return cls.create(dist_config["class_name"], **params)
|
|
@@ -1230,18 +1235,32 @@ class CombinationDistribution:
|
|
|
1230
1235
|
sample a combination of values from multiple distributions.
|
|
1231
1236
|
"""
|
|
1232
1237
|
|
|
1233
|
-
def __init__(self, *
|
|
1238
|
+
def __init__(self, *args: Distribution, dists=None):
|
|
1234
1239
|
"""
|
|
1235
|
-
|
|
1240
|
+
Initialise a combination distribution.
|
|
1241
|
+
|
|
1242
|
+
Distributions can be passed either as positional arguments or via the
|
|
1243
|
+
`dists` keyword argument, but not both. The keyword form is required
|
|
1244
|
+
when creating instances through the `DistributionRegistry` class,
|
|
1245
|
+
which passes parameters by name.
|
|
1236
1246
|
|
|
1237
1247
|
Parameters
|
|
1238
1248
|
----------
|
|
1239
|
-
*
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1249
|
+
*args : Distribution
|
|
1250
|
+
Distribution objects to combine, passed as positional arguments.
|
|
1251
|
+
E.g. `CombinationDistribution(d1, d2)`.
|
|
1252
|
+
Cannot be used together with `dists`.
|
|
1253
|
+
dists : Sequence[Distribution], optional
|
|
1254
|
+
Distribution objects to combine, passed as a keyword argument.
|
|
1255
|
+
E.g. `CombinationDistribution(dists=[d1, d2])`.
|
|
1256
|
+
Cannot be used together with `*args`.
|
|
1257
|
+
"""
|
|
1258
|
+
if args and dists is not None:
|
|
1259
|
+
raise ValueError(
|
|
1260
|
+
"Pass distributions either as positional arguments or as "
|
|
1261
|
+
"'dists', not both."
|
|
1262
|
+
)
|
|
1263
|
+
self.dists = dists if dists is not None else args
|
|
1245
1264
|
|
|
1246
1265
|
def __repr__(self):
|
|
1247
1266
|
dist_reprs = [repr(dist) for dist in self.dists]
|
|
@@ -2345,7 +2364,7 @@ class DiscreteEmpirical:
|
|
|
2345
2364
|
"""
|
|
2346
2365
|
|
|
2347
2366
|
# convert to array first
|
|
2348
|
-
self.values = np.asarray(values)
|
|
2367
|
+
self.values = np.asarray(list(values))
|
|
2349
2368
|
self.freq = np.asarray(freq)
|
|
2350
2369
|
|
|
2351
2370
|
validate(self.freq, "freq", is_positive_array)
|
|
@@ -2394,7 +2413,6 @@ class DiscreteEmpirical:
|
|
|
2394
2413
|
- A numpy array of values with shape determined by size parameter
|
|
2395
2414
|
"""
|
|
2396
2415
|
sample = self.rng.choice(self.values, p=self.probabilities, size=size)
|
|
2397
|
-
|
|
2398
2416
|
if size is None:
|
|
2399
2417
|
return sample.item()
|
|
2400
2418
|
return sample
|
|
@@ -10,7 +10,11 @@ import pandas as pd
|
|
|
10
10
|
import matplotlib.pyplot as plt
|
|
11
11
|
import itertools
|
|
12
12
|
|
|
13
|
+
from sim_tools.distributions import DistributionRegistry
|
|
14
|
+
|
|
15
|
+
|
|
13
16
|
# pylint: disable=too-few-public-methods
|
|
17
|
+
@DistributionRegistry.register()
|
|
14
18
|
class NSPPThinning:
|
|
15
19
|
"""
|
|
16
20
|
Non Stationary Poisson Process via Thinning.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|