reno.components.Distribution#

class reno.components.Distribution(*operands, per_timestep=False)#

Bases: EquationPart

Represents a probability distribution or set that is drawn from for each sample (n) in a simulation.

Probably shouldn’t directly be using this, although you can in theory likely pass in ``partial()``s with numpy functions (just minus the size variable.)

Methods

__init__(*operands[, per_timestep])

Create a distribution equation part, this is likely being called from a subclass.

astype(dtype)

Returns a symbolic operation to convert the output of this equation to the specified type.

clean_part_repr(part_index)

Get a non-"Scalar()" string version of a particular sub equation part.

clip(min, max)

Returns a symbolic operation for enforcing the output is between the passed min and max.

equal(obj)

Returns a symbolic operation for checking equality with passed object.

eval([t, save, force])

Get the vector of samples pulled from the probability distribution.

find_parts_of_type(search_type[, ...])

Recursively search for all EquationParts in the tree of the specified type.

get_shape()

Get the size of the additional "data" dimension.

get_type()

Get the type of the target output of this equation expression.

is_static()

Convenience shortcut for reno.utils.is_static() - True if this equation doesn't rely on any dynamic values (thus constant), False if it does.

latex(**kwargs)

Construct a string representation of this portion of the equation for use in a latex display.

mean([axis])

Returns a symbolic operation to find the series-wise mean of the array.

not_equal(obj)

Returns a symbolic operation for checking inequality with passed object.

populate(n[, steps, dim])

Generate n x dim samples based on this probability distribution, assigns as a vector/matrix to self.value.

pt(**refs)

Get a pytensor graph representing this piece of an equation.

pt_str(**refs)

Construct a string containing relevant pytensor code for this piece of the equation.

seek_refs([include_ref_types])

Recursively find a list of all References immediately underneath this part.

series_max()

Returns a symbolic operation to find the series-wise maximum of the array.

series_min()

Returns a symbolic operation to find the series-wise minimum of the array.

sum([axis])

Returns a symbolic operation to find the series-wise sum of the array.

Attributes

dtype

The type of each underlying value.

shape

The size of the data dimension, 1 by default.

timeseries

Returns symbolic operation for getting a timeseries view of the data.

Parameters:
__annotations__ = {}#
__module__ = 'reno.components'#
clean_part_repr(part_index)#

Get a non-“Scalar()” string version of a particular sub equation part.

Since all non-Scalar static values get converted into Scalar instances, this is used to remove all the “Scalar” strings everywhere e.g. in repr outputs. See ops.py __repr__ functions for examples of how it’s used.

Parameters:

part_index (int)

Return type:

str

eval(t=0, save=False, force=False, **kwargs)#

Get the vector of samples pulled from the probability distribution.

Note that this expects populate() to already have been called.

Parameters:
  • t (int)

  • save (bool)

  • force (bool)

  • kwargs (dict)

Return type:

ndarray

get_shape()#

Get the size of the additional “data” dimension.

Prefer using shape property over directly calling this function.

For a distribution we “broadcast” from any sub equation parts, so a >1 dim in a sub part will extend to this one.

Return type:

int

populate(n, steps=0, dim=1)#

Generate n x dim samples based on this probability distribution, assigns as a vector/matrix to self.value.

Parameters:
  • n (int) – Number of samples to draw.

  • steps (int) – Number of timesteps for which to draw samples for, only relevant if per_timestep is True.

  • dim (int) – If > 1, draw samples into a vector of this size for each n.

Return type:

None