parameterspace.parameters.integer
IntegerParameter
Integer parameter that can take every integer value in a given range.
check_numerical_value(self, numerical_value)
inherited
Check if the numerical representation of the value is valid.
Source code in parameterspace/parameters/integer.py
def check_numerical_value(self, numerical_value):
"""Check if the numerical representation of the value is valid."""
return (
self.transformed_bounds[0] <= numerical_value <= self.transformed_bounds[1]
)
check_value(self, value)
Check if value is valid.
Source code in parameterspace/parameters/integer.py
def check_value(self, value):
"""Check if value is valid."""
return self.bounds[0] <= value <= self.bounds[1] and value == int(value)
get_numerical_bounds(self)
inherited
Translate the provided bounds into the numerical representation.
Source code in parameterspace/parameters/integer.py
def get_numerical_bounds(self):
"""Translate the provided bounds into the numerical representation."""
return self.transformed_bounds
loglikelihood(self, value)
inherited
Compute the loglikelihood based on the prior.
Source code in parameterspace/parameters/integer.py
def loglikelihood(self, value):
"""Compute the loglikelihood based on the prior."""
return self.loglikelihood_numerical_value(self._transformation(value))
loglikelihood_numerical_value(self, numerical_value)
inherited
Compute the loglikelihood based on the prior.
Source code in parameterspace/parameters/integer.py
def loglikelihood_numerical_value(self, numerical_value):
"""Compute the loglikelihood based on the prior."""
return self._prior.loglikelihood(numerical_value) + np.log(
self._transformation.jacobian_factor(numerical_value)
)
num2val(self, numerical_value)
Translate the numerical representation into the actual value.
Source code in parameterspace/parameters/integer.py
def num2val(self, numerical_value):
"""Translate the numerical representation into the actual value."""
return int(super().num2val(numerical_value))
pdf_numerical_value(self, numerical_value)
inherited
Compute the PDF based on the prior.
Source code in parameterspace/parameters/integer.py
def pdf_numerical_value(self, numerical_value):
"""Compute the PDF based on the prior."""
return self._prior.pdf(numerical_value) * self._transformation.jacobian_factor(
numerical_value
)
sample_numerical_values(self, num_samples=None, random_state=<module 'numpy.random' from '/home/runner/.cache/pypoetry/virtualenvs/parameterspace-9AYrJA9h-py3.8/lib/python3.8/site-packages/numpy/random/__init__.py'>)
inherited
Generate random values based on the prior, but in the transformed space.
Source code in parameterspace/parameters/integer.py
def sample_numerical_values(self, num_samples=None, random_state=np.random):
"""Generate random values based on the prior, but in the transformed space."""
return self._prior.sample(num_samples, random_state=random_state)
sample_values(self, num_samples=None, random_state=<module 'numpy.random' from '/home/runner/.cache/pypoetry/virtualenvs/parameterspace-9AYrJA9h-py3.8/lib/python3.8/site-packages/numpy/random/__init__.py'>)
inherited
Generate randomly sampled values based on the prior.
Source code in parameterspace/parameters/integer.py
def sample_values(self, num_samples=None, random_state=np.random):
"""Generate randomly sampled values based on the prior."""
numerical_samples = self.sample_numerical_values(num_samples, random_state)
if num_samples is None:
return self._transformation.inverse(numerical_samples)
return [
self._transformation.inverse(num_value) for num_value in numerical_samples
]
val2num(self, value)
inherited
Translate a value into its numerical representation (incl. normalization).
Source code in parameterspace/parameters/integer.py
def val2num(self, value):
"""Translate a value into its numerical representation (incl. normalization)."""
if value is None:
return self._inactive_numerical_value
return self._transformation(value)