Domains¶
Introduction¶
A Domain
represents a collection of objects. They
are used by Simulatable
(and subclasses like
Model
and FiniteOutcomeModel
) to store
relevant information about the possible outcomes of a given
experiment.
This includes properties like whether or not there are
a finite number of possibilities, if so how many, and
what their data types are.
Domain
- Base Class for Domains¶
All domains should inherit from this base class.
Class Reference¶
-
class
qinfer.
Domain
[source]¶ Bases:
object
Abstract base class for domains of outcomes of models.
-
dtype
¶ The numpy dtype of a single element of the domain.
Type: np.dtype
-
n_members
¶ Returns the number of members in the domain if it
is_finite
, otherwise, returnsnp.inf
.Type: int
ornp.inf
-
example_point
¶ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1
np.array
of typedtype
.Type: np.ndarray
-
ProductDomain
- Cartesian product of multiple domains¶
Class Reference¶
-
class
qinfer.
ProductDomain
(*domains)[source]¶ Bases:
qinfer.domains.Domain
A domain made from the cartesian product of other domains.
Parameters: domains (Domain) – Domain
instances as separate arguments, or as a singe list ofDomain
instances.-
dtype
¶ The numpy dtype of a single element of the domain.
Type: np.dtype
-
n_members
¶ Returns the number of members in the domain if it
is_finite
, otherwise, returnsnp.inf
.Type: int
ornp.inf
-
example_point
¶ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1
np.array
of typedtype
.Type: np.ndarray
-
values
¶ Returns an
np.array
of typedtype
containing some values from the domain. For domains whereis_finite
isTrue
, all elements of the domain will be yielded exactly once.Return type: np.ndarray
-
to_regular_arrays
(array)[source]¶ Expands from an array of type
self.dtype
into a list of arrays with dtypes corresponding to the factor domains.Parameters: array (np.ndarray) – An np.array
of typeself.dtype
.Return type: list
-
RealDomain
- (A subset of) Real Numbers¶
Class Reference¶
-
class
qinfer.
RealDomain
(min=-inf, max=inf)[source]¶ Bases:
qinfer.domains.Domain
A domain specifying a contiguous (and possibly open ended) subset of the real numbers.
Parameters: -
dtype
¶ The numpy dtype of a single element of the domain.
Type: np.dtype
-
n_members
¶ Returns the number of members in the domain if it
is_finite
, otherwise, returnsNone
.Type: np.inf
-
example_point
¶ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1
np.array
of typedtype
.Type: np.ndarray
-
values
¶ Returns an
np.array
of typeself.dtype
containing some values from the domain. For domains whereis_finite
isTrue
, all elements of the domain will be yielded exactly once.Return type: np.ndarray
-
IntegerDomain
- (A subset of) Integers¶
This is the default domain for FiniteOutcomeModel
.
Class Reference¶
-
class
qinfer.
IntegerDomain
(min=0, max=inf)[source]¶ Bases:
qinfer.domains.Domain
A domain specifying a contiguous (and possibly open ended) subset of the integers.
Internally minimum and maximum are represented as floats in order to handle the case of infinite maximum, and minimums. The integer conversion function will be applied to the min and max values.
Parameters: Note: Yes, it is slightly unpythonic to specify
max
instead of `max`+1.-
dtype
¶ The numpy dtype of a single element of the domain.
Type: np.dtype
-
n_members
¶ Returns the number of members in the domain if it
is_finite
, otherwise, returnsnp.inf
.Type: int
ornp.inf
-
example_point
¶ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1
np.array
of typedtype
.Type: np.ndarray
-
values
¶ Returns an
np.array
of typeself.dtype
containing some values from the domain. For domains whereis_finite
isTrue
, all elements of the domain will be yielded exactly once.Return type: np.ndarray
-
MultinomialDomain
- Tuples of Integers with a Constant Sum¶
This domain is used by MultinomialModel
.
Class Reference¶
-
class
qinfer.
MultinomialDomain
(n_meas, n_elements=2)[source]¶ Bases:
qinfer.domains.Domain
A domain specifying k-tuples of non-negative integers which sum to a specific value.
Parameters: -
dtype
¶ The numpy dtype of a single element of the domain.
Type: np.dtype
-
n_members
¶ Returns the number of members in the domain if it
is_finite
, otherwise, returnsNone
.Type: int
-
example_point
¶ Returns any single point guaranteed to be in the domain, but no other guarantees; useful for testing purposes. This is given as a size 1
np.array
of typedtype
.Type: np.ndarray
-
values
¶ Returns an
np.array
of typeself.dtype
containing some values from the domain. For domains whereis_finite
isTrue
, all elements of the domain will be yielded exactly once.Return type: np.ndarray
-
to_regular_array
(A)[source]¶ Converts from an array of type
self.dtype
to an array of typeint
with an additional index labeling the tuple indeces.Parameters: A (np.ndarray) – An np.array
of typeself.dtype
.Return type: np.ndarray
-