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, 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
-
RealDomain
- (A subset of) Real Numbers¶
Class Reference¶
-
class
qinfer.
RealDomain
(min=None, max=None)[source]¶ Bases:
qinfer.domains.Domain
A domain specifying a contiguous (and possibly open ended) subset of the real numbers.
Parameters: -
min
¶ Returns the minimum value of the domain. The outcome
None
is interpreted as negative infinity.Return type: float
-
max
¶ Returns the maximum value of the domain. The outcome
None
is interpreted as positive infinity.Return type: float
-
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
-
IntegerDomain
- (A subset of) Integers¶
This is the default domain for FiniteOutcomeModel
.
Class Reference¶
-
class
qinfer.
IntegerDomain
(min=0, max=None)[source]¶ Bases:
qinfer.domains.Domain
A domain specifying a contiguous (and possibly open ended) subset of the integers.
Parameters: Note: Yes, it is slightly unpythonic to specify
max
instead of `max`+1.-
min
¶ Returns the minimum value of the domain. The outcome
None
is interpreted as negative infinity.Return type: float
-
max
¶ Returns the maximum value of the domain. The outcome
None
is interpreted as positive infinity.Return type: float
-
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
-
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
-