Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
87bd31a
feat(generator): unify mixture generators and support canonical forms
plidan123 May 10, 2025
08756db
refactor: Rename folder algorithms to procedures
May 13, 2025
1062e1c
refactor: Rename member functions algorithm to compute
May 24, 2025
bfdf571
refactor: Fix naming of estimators
May 24, 2025
76838d6
refactor: Update register names
May 25, 2025
7e47e63
refactor: Update register names
May 25, 2025
78a7b35
refactor: Update procedures class names
May 25, 2025
9fa4aad
refactor: update tests
May 28, 2025
3c5c1b2
feat: Add general interface StatisticalProcedure
May 31, 2025
1280bdf
feat: Implement dynamic integrator selection, enabling the use of cus…
Amellgo May 12, 2025
51a7303
feat: integration parameters are now part of the constructor
Amellgo Jun 1, 2025
947f956
refactor: Rename algorithm classes and folders
Jun 5, 2025
0d635b3
fix: Fixing errors from the previous commit
Jun 7, 2025
a2789f7
feat: add batch support and refactor mixture evaluation logic
plidan123 May 25, 2025
476758e
Merge pull request #40 from PySATL/api/abstract-integrator
plidan123 Jun 25, 2025
8ec30a0
Merge pull request #38 from PySATL/feat/unify-mixture-generators
plidan123 Jun 25, 2025
d29b60e
Merge branch 'update' into feat/unify-mixture
plidan123 Jun 25, 2025
4296e34
fixed
plidan123 Jun 25, 2025
12b3205
fixed
plidan123 Jun 25, 2025
1b5138d
fixed
plidan123 Jun 25, 2025
5f7295c
fixed
plidan123 Jun 25, 2025
1cebc58
Merge pull request #46 from PySATL/feat/unify-mixture
plidan123 Jun 25, 2025
2727050
fixed
plidan123 Jun 26, 2025
8d481af
fixed
plidan123 Jun 26, 2025
b1c944c
fixed
plidan123 Jun 26, 2025
d4e7c06
fixed
plidan123 Jun 26, 2025
cb90a63
fixed
plidan123 Jun 26, 2025
4ed9c3f
Merge pull request #44 from PySATL/api/renaming-of-statistical-proced…
plidan123 Jun 26, 2025
de0d635
fixed
plidan123 Jun 27, 2025
34a76ea
fixed
plidan123 Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Computes given integral with the limits of integration being 0 and 1 using Rando

### Usage:
```Python
from src.algorithms.support_algorithms.rqmc import RQMC
from src.procedures.support.rqmc import RQMC
rqmc = RQMC(lambda x: x**3 - x**2 + 1, error_tolerance=1e-5)
```
So `rqmc()[0]` is estimated integral value and `rqmc()[1]` is current error tolerance.
Expand Down
2 changes: 1 addition & 1 deletion jupiter_examples/nm_sigma_estimation_comparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
" \"\"\"\n",
" generator = NMGenerator()\n",
" mixture = NormalMeanMixtures(\"canonical\", sigma=real_sigma, distribution=distribution)\n",
" return generator.canonical_generate(mixture, sample_len)\n",
" return generator.generate(mixture, sample_len)\n",
"\n",
"def estimate_sigma_eigenvalue_based(sample, real_sigma, search_area, a, b):\n",
" sample_len = len(sample)\n",
Expand Down
46 changes: 0 additions & 46 deletions src/algorithms/__init__.py

This file was deleted.

121 changes: 0 additions & 121 deletions src/algorithms/support_algorithms/log_rqmc.py

This file was deleted.

6 changes: 3 additions & 3 deletions src/estimators/abstract_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from numpy import _typing

from src.algorithms import ALGORITHM_REGISTRY
from src.procedures import ALGORITHM_REGISTRY
from src.estimators.estimate_result import EstimateResult
from src.register.algorithm_purpose import AlgorithmPurpose

Expand All @@ -14,7 +14,7 @@ class AbstractEstimator:
algorithm_name: A string indicating chosen algorithm.
params: A dictionary of algorithm parameters.
estimate_result: Estimation result.
_registry: Registry that contains classes of all algorithms.
_registry: Registry that contains classes of all procedures.
_purpose: Defines purpose of algorithm, one of the registry key.
"""

Expand Down Expand Up @@ -47,7 +47,7 @@ def set_params(self, algorithm_name: str, params: dict | None = None) -> Self:
return self

def get_available_algorithms(self) -> list[str]:
"""Get all algorithms that can be used for current estimator class"""
"""Get all procedures that can be used for current estimator class"""
return [key[0] for key in self._registry.register_of_names.keys() if key[1] == self._purpose]

def estimate(self, sample: _typing.ArrayLike) -> EstimateResult:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from src.estimators.estimate_result import EstimateResult


class AbstractSemiParametricEstimator(AbstractEstimator):
class AbstractSemiparEstim(AbstractEstimator):
def __init__(self, algorithm_name: str, params: dict | None = None) -> None:
super().__init__(algorithm_name, params)

Expand Down
4 changes: 2 additions & 2 deletions src/estimators/semiparametric/nm_semiparametric_estimator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from numpy import _typing

from src.estimators.estimate_result import EstimateResult
from src.estimators.semiparametric.abstract_semiparametric_estimator import AbstractSemiParametricEstimator
from src.estimators.semiparametric.abstract_semiparametric_estimator import AbstractSemiparEstim
from src.register.algorithm_purpose import AlgorithmPurpose


class NMSemiParametricEstimator(AbstractSemiParametricEstimator):
class NMSemiparEstim(AbstractSemiparEstim):
def __init__(self, algorithm_name: str, params: dict | None = None) -> None:
super().__init__(algorithm_name, params)
self._purpose = AlgorithmPurpose.NM_SEMIPARAMETRIC
Expand Down
4 changes: 2 additions & 2 deletions src/estimators/semiparametric/nmv_semiparametric_estimator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from numpy import _typing

from src.estimators.estimate_result import EstimateResult
from src.estimators.semiparametric.abstract_semiparametric_estimator import AbstractSemiParametricEstimator
from src.estimators.semiparametric.abstract_semiparametric_estimator import AbstractSemiparEstim
from src.register.algorithm_purpose import AlgorithmPurpose


class NMVSemiParametricEstimator(AbstractSemiParametricEstimator):
class NMVSemiparEstim(AbstractSemiparEstim):
def __init__(self, algorithm_name: str, params: dict | None = None) -> None:
super().__init__(algorithm_name, params)
self._purpose = AlgorithmPurpose.NMV_SEMIPARAMETRIC
Expand Down
4 changes: 2 additions & 2 deletions src/estimators/semiparametric/nv_semiparametric_estimator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from numpy import _typing

from src.estimators.estimate_result import EstimateResult
from src.estimators.semiparametric.abstract_semiparametric_estimator import AbstractSemiParametricEstimator
from src.estimators.semiparametric.abstract_semiparametric_estimator import AbstractSemiparEstim
from src.register.algorithm_purpose import AlgorithmPurpose


class NVSemiParametricEstimator(AbstractSemiParametricEstimator):
class NVSemiparEstim(AbstractSemiparEstim):
def __init__(self, algorithm_name: str, params: dict | None = None) -> None:
super().__init__(algorithm_name, params)
self._purpose = AlgorithmPurpose.NV_SEMIPARAMETRIC
Expand Down
25 changes: 3 additions & 22 deletions src/generators/nm_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class NMGenerator(AbstractGenerator):

@staticmethod
def classical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
def generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
"""Generate a sample of given size. Classical form of NMM

Args:
Expand All @@ -27,25 +27,6 @@ def classical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
raise ValueError("Mixture must be NormalMeanMixtures")
mixing_values = mixture.params.distribution.rvs(size=size)
normal_values = scipy.stats.norm.rvs(size=size)
if mixture.mixture_form == "canonical":
return mixing_values + mixture.params.sigma * normal_values
return mixture.params.alpha + mixture.params.beta * mixing_values + mixture.params.gamma * normal_values

@staticmethod
def canonical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
"""Generate a sample of given size. Canonical form of NMM

Args:
mixture: Normal Mean Mixture
size: length of sample

Returns: sample of given size

Raises:
ValueError: If mixture is not a Normal Mean Mixture

"""

if not isinstance(mixture, NormalMeanMixtures):
raise ValueError("Mixture must be NormalMeanMixtures")
mixing_values = mixture.params.distribution.rvs(size=size)
normal_values = scipy.stats.norm.rvs(size=size)
return mixing_values + mixture.params.sigma * normal_values
27 changes: 4 additions & 23 deletions src/generators/nmv_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class NMVGenerator(AbstractGenerator):

@staticmethod
def classical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
def generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
"""Generate a sample of given size. Classical form of NMVM

Args:
Expand All @@ -27,29 +27,10 @@ def classical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
raise ValueError("Mixture must be NormalMeanMixtures")
mixing_values = mixture.params.distribution.rvs(size=size)
normal_values = scipy.stats.norm.rvs(size=size)
if mixture.mixture_form == "canonical":
return mixture.params.alpha + mixture.params.mu * mixing_values + (mixing_values ** 0.5) * normal_values
return (
mixture.params.alpha
+ mixture.params.beta * mixing_values
+ mixture.params.gamma * (mixing_values**0.5) * normal_values
)

@staticmethod
def canonical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
"""Generate a sample of given size. Canonical form of NMVM

Args:
mixture: Normal Mean Variance Mixtures
size: length of sample

Returns: sample of given size

Raises:
ValueError: If mixture type is not Normal Mean Variance Mixtures

"""

if not isinstance(mixture, NormalMeanVarianceMixtures):
raise ValueError("Mixture must be NormalMeanMixtures")
mixing_values = mixture.params.distribution.rvs(size=size)
normal_values = scipy.stats.norm.rvs(size=size)
return mixture.params.alpha + mixture.params.mu * mixing_values + (mixing_values**0.5) * normal_values
)
27 changes: 4 additions & 23 deletions src/generators/nv_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class NVGenerator(AbstractGenerator):

@staticmethod
def classical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
def generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
"""Generate a sample of given size. Classical form of NVM

Args:
Expand All @@ -27,25 +27,6 @@ def classical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
raise ValueError("Mixture must be NormalMeanMixtures")
mixing_values = mixture.params.distribution.rvs(size=size)
normal_values = scipy.stats.norm.rvs(size=size)
return mixture.params.alpha + mixture.params.gamma * (mixing_values**0.5) * normal_values

@staticmethod
def canonical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray:
"""Generate a sample of given size. Canonical form of NVM

Args:
mixture: Normal Variance Mixtures
size: length of sample

Returns: sample of given size

Raises:
ValueError: If mixture type is not Normal Variance Mixtures

"""

if not isinstance(mixture, NormalVarianceMixtures):
raise ValueError("Mixture must be NormalMeanMixtures")
mixing_values = mixture.params.distribution.rvs(size=size)
normal_values = scipy.stats.norm.rvs(size=size)
return mixture.params.alpha + (mixing_values**0.5) * normal_values
if mixture.mixture_form == "canonical":
return mixture.params.alpha + (mixing_values ** 0.5) * normal_values
return mixture.params.alpha + mixture.params.gamma * (mixing_values**0.5) * normal_values
Loading
Loading