# optuna.distributions.DiscreteUniformDistribution¶

class optuna.distributions.DiscreteUniformDistribution(low: float, high: float, q: float)[source]

A discretized uniform distribution in the linear domain.

This object is instantiated by suggest_discrete_uniform(), and passed to samplers in general.

Note

If the range $$[\mathsf{low}, \mathsf{high}]$$ is not divisible by $$q$$, $$\mathsf{high}$$ will be replaced with the maximum of $$k q + \mathsf{low} \lt \mathsf{high}$$, where $$k$$ is an integer.

low

Lower endpoint of the range of the distribution. low is included in the range.

high

Upper endpoint of the range of the distribution. high is included in the range.

q

A discretization step.

__init__(low: float, high: float, q: float)None[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

 __init__(low, high, q) Initialize self. Test whether the range of this distribution contains just a single value. to_external_repr(param_value_in_internal_repr) Convert internal representation of a parameter value into external representation. to_internal_repr(param_value_in_external_repr) Convert external representation of a parameter value into internal representation.
single()bool[source]

Test whether the range of this distribution contains just a single value.

When this method returns True, samplers always sample the same value from the distribution.

Returns

True if the range of this distribution contains just a single value, otherwise False.

to_external_repr(param_value_in_internal_repr: float) → Any

Convert internal representation of a parameter value into external representation.

Parameters

param_value_in_internal_repr – Optuna’s internal representation of a parameter value.

Returns

Optuna’s external representation of a parameter value.

to_internal_repr(param_value_in_external_repr: Any)float

Convert external representation of a parameter value into internal representation.

Parameters

param_value_in_external_repr – Optuna’s external representation of a parameter value.

Returns

Optuna’s internal representation of a parameter value.