symbolic_pymc.theano package

Submodules

symbolic_pymc.theano.dispatch module

symbolic_pymc.theano.meta module

class symbolic_pymc.theano.meta.TheanoMetaAccessor(namespace=None)

Bases: object

Create an object that can be used to implicitly convert Theano functions and objects into meta objects.

Use it like a namespace/module/package object, e.g.

>>> mt = TheanoMetaAccessor()
>>> mt.vector('a')
MetaTensorVariable(MetaTensorType('float64', (False,), None,
obj=TensorType(float64, vector)), None, None, 'a', obj=a)

Call it as a function to perform direct conversion to a meta object, e.g.

>>> mt(tt.vector('a'))
MetaTensorVariable(MetaTensorType('float64', (False,), None,
obj=TensorType(float64, vector)), None, None, 'a', obj=a)
namespaces = [<module 'theano.tensor' from '/home/bwillard/apps/anaconda3/envs/symbolic-pymc/lib/python3.7/site-packages/theano/tensor/__init__.py'>, <module 'symbolic_pymc.theano.meta' from '/home/bwillard/projects/code/python/symbolic-pymc/symbolic_pymc/theano/meta.py'>, <module 'symbolic_pymc.theano.ops' from '/home/bwillard/projects/code/python/symbolic-pymc/symbolic_pymc/theano/ops.py'>, <module 'symbolic_pymc.theano.random_variables' from '/home/bwillard/projects/code/python/symbolic-pymc/symbolic_pymc/theano/random_variables.py'>]
class symbolic_pymc.theano.meta.TheanoMetaApply(op, inputs, outputs=None, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaSymbol

base

alias of theano.gof.graph.Apply

inputs
property nin
property nout
op
property outputs
reify()

Attempt to create a concrete base object from this meta object.

During the process, dependent objects will need to be reified, which may result in updates to the object(s) being reified.

For instance, if a meta tensor’s parent operator is fully reifiable to a base object, then the meta tensor’s dtype and shape may be fixed: e.g. a tensor corresponding to the output of a sum of two float64 scalars is necessarily a float64 scalar.

This function will set any unspecified properties (e.g. dtype and shape values for the previous example), mutating the object in-place when possible. It will return a [refined/partially reified] meta object when it can’t fully reify to a base object (in which case, it will return the base object) or when partial reification results in a meta object from a subclass.

reset()
class symbolic_pymc.theano.meta.TheanoMetaConstant(type, data, name=None, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaVariable

base

alias of theano.gof.graph.Constant

data
reset()
class symbolic_pymc.theano.meta.TheanoMetaDimShuffle(input_broadcastable, new_order, inplace=True, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaOp

Initialize a meta Op.

base

alias of theano.tensor.elemwise.DimShuffle

inplace
input_broadcastable
new_order
reset()
class symbolic_pymc.theano.meta.TheanoMetaElemwise(*args, obj=None, **kwargs)

Bases: symbolic_pymc.theano.meta.TheanoMetaOp

Initialize a meta Op.

base

alias of theano.tensor.elemwise.Elemwise

reset()
class symbolic_pymc.theano.meta.TheanoMetaOp(*args, obj=None, **kwargs)

Bases: symbolic_pymc.meta.MetaOp, symbolic_pymc.theano.meta.TheanoMetaSymbol

A meta object that represents Theano `Op`s.

NOTE: By default it will use Op.make_node’s signature to produce meta Apply node inputs, so be sure to override that signature (at the class level) when Op.make_node’s arguments aren’t one-to-one with the expected Apply node inputs. See MetaOp.__call__ for more details.

Also, make sure to override Op.output_meta_types and make it return the expected meta variable types, if it isn’t the default: TheanoMetaTensorVariable.

Initialize a meta Op.

base

alias of theano.gof.op.PureOp

output_meta_types(inputs=None)

Return the types of meta variables this Op is expected to produce given the inputs.

The default is TheanoMetaTensorVariable (corresponding to TheanoTensorVariable outputs from the base Op).

reset()
class symbolic_pymc.theano.meta.TheanoMetaOpType

Bases: symbolic_pymc.meta.MetaSymbolType

class symbolic_pymc.theano.meta.TheanoMetaRandomStateType(obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaType

base

alias of theano.tensor.raw_random.RandomStateType

reset()
class symbolic_pymc.theano.meta.TheanoMetaScalarSharedVariable(name, type, data, strict, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaSharedVariable

base

alias of theano.tensor.sharedvar.ScalarSharedVariable

reset()
class symbolic_pymc.theano.meta.TheanoMetaScan(inputs, outputs, info, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaOp

Initialize a meta Op.

base

alias of theano.scan_module.scan_op.Scan

info
inputs
outputs
reset()
class symbolic_pymc.theano.meta.TheanoMetaSharedVariable(name, type, data, strict, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaVariable

base

alias of theano.compile.sharedvalue.SharedVariable

data
reset()
strict
class symbolic_pymc.theano.meta.TheanoMetaSymbol(obj=None)

Bases: symbolic_pymc.meta.MetaSymbol

reset()
class symbolic_pymc.theano.meta.TheanoMetaTensorConstant(type, data, name=None, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaConstant

base

alias of theano.tensor.var.TensorConstant

property ndim
reset()
class symbolic_pymc.theano.meta.TheanoMetaTensorSharedVariable(name, type, data, strict, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaSharedVariable

base

alias of theano.tensor.sharedvar.TensorSharedVariable

reset()
class symbolic_pymc.theano.meta.TheanoMetaTensorType(dtype, broadcastable, name, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaType

base

alias of theano.tensor.type.TensorType

broadcastable
dtype
name
reset()
class symbolic_pymc.theano.meta.TheanoMetaTensorVariable(type, owner, index, name, obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaVariable

base

alias of theano.tensor.var.TensorVariable

property ndim
reset()
class symbolic_pymc.theano.meta.TheanoMetaType(obj=None)

Bases: symbolic_pymc.theano.meta.TheanoMetaSymbol

base

alias of theano.gof.type.Type

reset()
class symbolic_pymc.theano.meta.TheanoMetaVariable(type, owner, index, name, obj=None)

Bases: symbolic_pymc.meta.MetaVariable, symbolic_pymc.theano.meta.TheanoMetaSymbol

base

alias of theano.gof.graph.Variable

property base_arguments

Return the base-level arguments.

These arguments used in conjunction with the callable self.base_operator should re-produce this variable.

property base_operator

Return a meta object representing a base-level operator.

It should be callable with all inputs necessary to reproduce this tensor given by self.base_arguments.

index
name
owner
reify()

Attempt to create a concrete base object from this meta object.

During the process, dependent objects will need to be reified, which may result in updates to the object(s) being reified.

For instance, if a meta tensor’s parent operator is fully reifiable to a base object, then the meta tensor’s dtype and shape may be fixed: e.g. a tensor corresponding to the output of a sum of two float64 scalars is necessarily a float64 scalar.

This function will set any unspecified properties (e.g. dtype and shape values for the previous example), mutating the object in-place when possible. It will return a [refined/partially reified] meta object when it can’t fully reify to a base object (in which case, it will return the base object) or when partial reification results in a meta object from a subclass.

reset()
type
symbolic_pymc.theano.meta.load_dispatcher()

Set/override dispatcher to default to TF objects.

symbolic_pymc.theano.meta.mt_diag(v, k=0)
symbolic_pymc.theano.meta.mt_zeros(shape, dtype=None)

symbolic_pymc.theano.ops module

class symbolic_pymc.theano.ops.RandomVariable(name, dtype, ndim_supp, ndims_params, rng_fn, *args, supp_shape_fn=<function param_supp_shape_fn>, inplace=False, **kwargs)

Bases: theano.gof.op.Op

An Op that produces a sample from a random variable.

This is essentially RandomFunction, except that it removes the outtype dependency and handles shape dimension information more directly.

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

R_op(inputs, eval_points)

This method is primarily used by tensor.Rop

Suppose the op outputs

[ f_1(inputs), …, f_n(inputs) ]

inputs : a Variable or list of Variables eval_points

A Variable or list of Variables with the same length as inputs. Each element of eval_points specifies the value of the corresponding input at the point where the R op is to be evaluated.

list of n elements
rval[i] should be Rop(f=f_i(inputs),

wrt=inputs, eval_points=eval_points)

compute_bcast(dist_params, size)

Compute the broadcast array for this distribution’s TensorType.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

default_output = 1
grad(inputs, outputs)
infer_shape(node, input_shapes)
make_node(*dist_params, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

nondeterministic = True
perform(node, inputs, outputs)

Draw samples using Numpy/SciPy.

symbolic_pymc.theano.ops.param_supp_shape_fn(ndim_supp, ndims_params, dist_params, rep_param_idx=0, param_shapes=None)

Infer dimensions for a random variable.

This is a function that derives a random variable’s support shape/dimensions from one of its parameters.

XXX: It’s not always possible to determine a random variable’s support shape from its parameters, so this function has fundamentally limited applicability.

XXX: This function is not expected to handle ndim_supp = 0 (i.e. scalars), since that is already definitively handled in the Op that calls this.

TODO: Consider using theano.compile.ops.shape_i alongside ShapeFeature.

ndim_supp: int

Total number of dimensions in the support (assumedly > 0).

ndims_params: list of int

Number of dimensions for each distribution parameter.

dist_params: list of theano.gof.graph.Variable

The distribution parameters.

param_shapes: list of theano.compile.ops.Shape (optional)

Symbolic shapes for each distribution parameter. Providing this value prevents us from reproducing the requisite theano.compile.ops.Shape object (e.g. when it’s already available to the caller).

rep_param_idx: int (optional)

The index of the distribution parameter to use as a reference In other words, a parameter in dist_param with a shape corresponding to the support’s shape. The default is the first parameter (i.e. the value 0).

out: a tuple representing the support shape for a distribution with the given dist_params.

symbolic_pymc.theano.opt module

class symbolic_pymc.theano.opt.FunctionGraph(inputs, outputs, features=None, clone=True, memo=None, update_mapping=None, copy_inputs=True, copy_orphans=None)

Bases: theano.gof.fg.FunctionGraph

A version of FunctionGraph that knows not to merge non-deterministic `Op`s.

TODO: Add a check to MergeFeature.process_node and submit a PR to Theano.

Create an FunctionGraph which operates on the subgraph bound by the inputs and outputs sets.

inputslist of variables

Inputs nodes of the graph, usually declared by the user

outputslist of variables

Outputs nodes of the graph.

cloneboolean

If true, we will clone the graph. This is useful to remove the constant cache problem.

update_mappingdictionary

Mapping between the inputs with updates and the outputs corresponding to their updates.

attach_feature(feature)

Adds a gof.toolbox.Feature to this function_graph and triggers its on_attach callback.

clone_get_equiv(*args, **kwargs)

Clone the graph and get a dict that maps old nodes to new ones

Parameters:
check_integrity: bool

Whether to check integrity. Default is True.

attach_feature: bool

Whether to attach feature of origin graph to cloned graph. Default is True.

Returns:
e: FunctionGraph

Cloned fgraph. Every node in cloned graph is cloned.

equiv: dict

A dict that map old node to new node.

replace(r, new_r, reason=None, verbose=None, remove_dup_inputs=True)

See theano.gof.fg.FunctionGraph.replace.

The original FunctionGraph.replace will not replace the actual input list. This one will.

class symbolic_pymc.theano.opt.KanrenRelationSub(kanren_relation, relation_lvars=None, results_filter=<function KanrenRelationSub.<lambda>>, node_filter=<function KanrenRelationSub.<lambda>>)

Bases: theano.gof.opt.LocalOptimizer

A local optimizer that uses miniKanren goals to match and replace terms in a Theano FunctionGraph.

TODO: Only uses one miniKanren run result (chosen by a configurable filter function). We might want an option to produce multiple graphs, but I imagine that would involve an entirely different optimizer type.

Create a KanrenRelationSub.

kanren_relation: kanren.Relation or goal

The miniKanren relation store or goal to use. Custom goals should take an input and output argument, respectively.

relation_lvars: Iterable

A collection of terms to be considered logic variables by miniKanren (i.e. Theano terms used as “unknowns” in kanren_relation).

results_filter: function

A function that returns a single result from a stream of miniKanren results. The default function returns the first result.

node_filter: function

A function taking a single node as an argument that returns True when the node should be skipped.

adjust_outputs(node, new_node, old_node=None)

Make adjustments for multiple outputs.

This handles (some) nodes with multiple outputs by returning a list with the appropriate length and containing the new node (at the correct index if default_output is available and correct, or 0–and it happens to be the correct one).

TODO: We should be able to get the correct index from the something like node.outputs.index(old_node), but we don’t exactly have old_node unless the miniKanren results give it to us.

reentrant = True
transform(node)

Transform a subgraph whose output is node.

Subclasses should implement this function so that it returns one of two kinds of things:

  • False to indicate that no optimization can be applied to this node; or

  • <list of variables> to use in place of node’s outputs in the greater graph.

  • dict(old variables -> new variables). A dictionary that map from old variables to new variables to replace.

node : an Apply instance

symbolic_pymc.theano.opt.eval_and_reify_meta(x)

Get Theano objects from combinations of `etuple`s and meta objects.

symbolic_pymc.theano.printing module

class symbolic_pymc.theano.printing.GenericSubtensorPrinter

Bases: object

process(r, pstate)
class symbolic_pymc.theano.printing.NormalRVPrinter

Bases: symbolic_pymc.theano.printing.RandomVariablePrinter

Create a RandomVariablePrinter.

name: str (optional)

A fixed name to use for the random variables printed by this printer. If not specified, use RandomVariable.name.

process_param(idx, sform, pstate)

Perform special per-parameter post-formatting.

This can be used, for instance, to change a std. dev. into a variance.

idx: int

The index value of the parameter.

sform: str

The pre-formatted string form of the parameter.

pstate: object

The printer state.

class symbolic_pymc.theano.printing.ObservationPrinter

Bases: object

process(output, pstate)
class symbolic_pymc.theano.printing.PreamblePPrinter(*args, pstate_defaults=None, preamble_dict=None, **kwargs)

Bases: theano.printing.PPrinter

Pretty printer that displays a preamble.

Preambles are put into an OrderedDict of categories (determined by printers that use the preamble). The order can be set by preempting the category names within an OrderedDict passed to the constructor via the preamble_dict keyword. The lines accumulated in each category are comma-separated up to a fixed length given by PreamblePPrinter.max_preamble_width, after which a newline is appended and process repeats.

>>> import theano.tensor as tt
>>> from symbolic_pymc import NormalRV
>>> from symbolic_pymc.printing import tt_pprint
>>> X_rv = NormalRV(tt.scalar('\\mu'), tt.scalar('\\sigma'), name='X')
>>> print(tt_pprint(X_rv))
\\mu in R
\\sigma in R
X ~ N(\\mu, \\sigma**2),  X in R
X

XXX: Not thread-safe!

Create a PreamblePPrinter.

pstate_defaults: dict (optional)

Default printer state parameters.

preamble_dict: OrderedDict (optional)

Default preamble dictionary. Use this to pre-set the print-out ordering of preamble categories/keys.

create_state(pstate)
max_preamble_width = 40
process(r, pstate=None)
process_graph(inputs, outputs, updates=None, display_inputs=False)
class symbolic_pymc.theano.printing.RandomVariablePrinter(name=None)

Bases: object

Pretty print random variables.

Op`s are able to specify their ascii and LaTeX formats via a “print_name” property. `Op.print_name should be a tuple or list that specifies the plain text/ascii and LaTeX name, respectively.

Also, distribution parameters can be formatted distinctly by overriding the RandomVariablePrinter.process_param method.

Create a RandomVariablePrinter.

name: str (optional)

A fixed name to use for the random variables printed by this printer. If not specified, use RandomVariable.name.

process(output, pstate)
process_param(idx, sform, pstate)

Perform special per-parameter post-formatting.

This can be used, for instance, to change a std. dev. into a variance.

idx: int

The index value of the parameter.

sform: str

The pre-formatted string form of the parameter.

pstate: object

The printer state.

class symbolic_pymc.theano.printing.VariableWithShapePrinter

Bases: object

Print variable shape info in the preamble.

Also uses readable character names for un-named variables.

Constant arrays are only printed when their size is below a threshold set by max_line_width * max_line_height

available_names = {'A': None, 'B': None, 'C': None, 'D': None, 'E': None, 'F': None, 'G': None, 'H': None, 'I': None, 'J': None, 'K': None, 'L': None, 'M': None, 'N': None, 'O': None, 'P': None, 'Q': None, 'R': None, 'S': None, 'T': None, 'U': None, 'V': None, 'W': None, 'X': None, 'Y': None, 'Z': None, 'a': None, 'b': None, 'c': None, 'd': None, 'e': None, 'f': None, 'g': None, 'h': None, 'i': None, 'j': None, 'k': None, 'l': None, 'm': None, 'n': None, 'o': None, 'p': None, 'q': None, 'r': None, 's': None, 't': None, 'u': None, 'v': None, 'w': None, 'x': None, 'y': None, 'z': None}
default_printer = <theano.printing.DefaultPrinter object>
max_line_height = 20
max_line_width = 40
classmethod process(output, pstate)
classmethod process_shape_info(output, pstate)
classmethod process_variable_name(output, pstate)

Take a variable name from the available ones.

This function also initializes the available names by removing all the manually specified names within the FunctionGraph being printed (if available). Doing so removes the potential for name collisions.

symbolic_pymc.theano.printing.latex_print_array(data)

symbolic_pymc.theano.pymc3 module

symbolic_pymc.theano.pymc3.convert_dist_to_rv_Bernoulli(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Beta(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_BetaBinomial(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Binomial(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Categorical(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Cauchy(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Dirichlet(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Exponential(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Gamma(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_HalfCauchy(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_HalfNormal(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_InverseGamma(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Multinomial(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_MvNormal(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Normal(dist, rng)
symbolic_pymc.theano.pymc3.convert_dist_to_rv_Poisson(dist, rng)
symbolic_pymc.theano.pymc3.graph_model(graph, *model_args, **model_kwargs)

Create a PyMC3 model from a Theano graph with RandomVariable nodes.

symbolic_pymc.theano.pymc3.model_graph(pymc_model, output_vars=None, rand_state=None, attach_memo=True)

Convert a PyMC3 model into a Theano FunctionGraph.

pymc_model: Model

A PyMC3 model object.

output_vars: list (optional)

Variables to use as FunctionGraph outputs. If not specified, the model’s observed random variables are used.

rand_state: Numpy rng (optional)

When converting to `RandomVariable`s, use this random state object.

attach_memo: boolean (optional)

Add a property to the returned FunctionGraph name memo that contains the mappings between PyMC and RandomVariable terms.

out: FunctionGraph

symbolic_pymc.theano.pymc3.pymc3_var_to_rv(pm_var, rand_state=None)

Convert a PyMC3 random variable into a RandomVariable.

symbolic_pymc.theano.pymc3.rec_conv_to_rv(v, replacements, model, rand_state=None)

Recursively convert a PyMC3 random variable to a Theano graph.

symbolic_pymc.theano.pymc3.tt_get_values(obj)

Get the value of a Theano constant or shared variable.

symbolic_pymc.theano.random_variables module

class symbolic_pymc.theano.random_variables.BernoulliRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(p, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Bern', '\\operatorname{Bern}')
class symbolic_pymc.theano.random_variables.BetaBinomialRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(n, a, b, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('BetaBinom', '\\operatorname{BetaBinom}')
class symbolic_pymc.theano.random_variables.BetaRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(alpha, beta, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Beta', '\\operatorname{Beta}')
class symbolic_pymc.theano.random_variables.BinomialRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(n, p, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Binom', '\\operatorname{Binom}')
class symbolic_pymc.theano.random_variables.CategoricalRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(pvals, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Cat', '\\operatorname{Cat}')
class symbolic_pymc.theano.random_variables.CauchyRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(loc, scale, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('C', '\\operatorname{C}')
class symbolic_pymc.theano.random_variables.DirichletRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(alpha, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Dir', '\\operatorname{Dir}')
class symbolic_pymc.theano.random_variables.ExponentialRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(scale, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Exp', '\\operatorname{Exp}')
class symbolic_pymc.theano.random_variables.GammaRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(shape, scale, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Gamma', '\\operatorname{Gamma}')
class symbolic_pymc.theano.random_variables.HalfCauchyRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(loc=0.0, scale=1.0, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('C**+', '\\operatorname{C^{+}}')
class symbolic_pymc.theano.random_variables.HalfNormalRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(mu=0.0, sigma=1.0, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('N**+', '\\operatorname{N^{+}}')
class symbolic_pymc.theano.random_variables.InvGammaRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(a, loc=0.0, scale=1.0, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('InvGamma', '\\operatorname{Gamma^{-1}}')
class symbolic_pymc.theano.random_variables.MultinomialRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(n, pvals, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('MN', '\\operatorname{MN}')
class symbolic_pymc.theano.random_variables.MvNormalRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(mean, cov, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('N', '\\operatorname{N}')
class symbolic_pymc.theano.random_variables.NormalRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(mu, sigma, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('N', '\\operatorname{N}')
class symbolic_pymc.theano.random_variables.Observed

Bases: theano.gof.op.Op

An Op that represents an observed random variable.

This Op establishes an observation relationship between a random variable and a specific value.

default_output = 0
grad(inputs, outputs)
make_node(val, rv=None)

Make an Observed random variable.

val: Variable

The observed value.

rv: RandomVariable

The distribution from which val is assumed to be a sample value.

perform(node, inputs, out)

Required: Calculate the function on the inputs and put the variables in the output storage. Return None.

nodeApply instance

Contains the symbolic inputs and outputs.

inputslist

Sequence of inputs (immutable).

output_storagelist

List of mutable 1-element lists (do not change the length of these lists)

The output_storage list might contain data. If an element of output_storage is not None, it has to be of the right type, for instance, for a TensorVariable, it has to be a Numpy ndarray, with the right number of dimensions, and the correct dtype. Its shape and stride pattern, can be arbitrary. It not is guaranteed that it was produced by a previous call to impl. It could be allocated by another Op impl is free to reuse it as it sees fit, or to discard it and allocate new memory.

MethodNotDefined

The subclass does not override this method.

class symbolic_pymc.theano.random_variables.PoissonRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(rate, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('Pois', '\\operatorname{Pois}')
class symbolic_pymc.theano.random_variables.TruncExponentialRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(b, loc=0.0, scale=1.0, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('TruncExp', '\\operatorname{Exp}')
class symbolic_pymc.theano.random_variables.UniformRVType

Bases: symbolic_pymc.theano.ops.RandomVariable

Create a random variable Op.

name: str

The Op’s display name.

dtype: Theano dtype

The underlying dtype.

ndim_supp: int

Dimension of the support. This value is used to infer the exact shape of the support and independent terms from dist_params.

ndims_params: tuple (int)

Number of dimensions of each parameter in dist_params.

rng_fn: function or str

The non-symbolic random variate sampling function. Can be the string name of a method provided by numpy.random.RandomState.

supp_shape_fn: callable (optional)

Function used to determine the exact shape of the distribution’s support.

It must take arguments ndim_supp, ndims_params, dist_params (i.e. an collection of the distribution parameters) and an optional param_shapes (i.e. tuples containing the size of each dimension for each distribution parameter).

Defaults to param_supp_shape_fn.

inplace: boolean (optional)

Determine whether or not the underlying rng state is updated in-place or not (i.e. copied).

make_node(lower, upper, size=None, rng=None, name=None)

Create a random variable node.

XXX: Unnamed/non-keyword arguments are considered distribution parameters! If you want to set size, rng, and/or name, use their keywords.

dist_params: list

Distribution parameters.

size: int or Iterable (optional)

Numpy-like size of the output (i.e. replications).

rng: RandomState (optional)

Existing Theano RandomState object to be used. Creates a new one, if None.

name: str (optional)

Label for the resulting node.

out: Apply

A node with inputs dist_args + (size, in_rng, name) and outputs (out_rng, sample_tensorvar).

print_name = ('U', '\\operatorname{U}')

symbolic_pymc.theano.utils module

symbolic_pymc.theano.utils.canonicalize(x, **kwargs)

Canonicalize a Theano variable and/or graph.

symbolic_pymc.theano.utils.get_rv_observation(node)

Return a RandomVariable node’s corresponding Observed node, or None.

symbolic_pymc.theano.utils.graph_equal(x, y)

Compare elements in a Theano graph using their object properties and not just identity.

symbolic_pymc.theano.utils.optimize_graph(x, optimization, return_graph=None, in_place=False)

Easily optimize Theano graphs.

Apply an optimization to either the graph formed by a Theano variable or an existing graph and return the resulting optimized graph.

When given an existing FunctionGraph, the optimization is performed without side-effects (i.e. won’t change the given graph).

symbolic_pymc.theano.utils.replace_input_nodes(inputs, outputs, replacements=None, memo=None, clone_inputs=True)

Recreate a graph, replacing input variables according to a given map.

This is helpful if you want to replace the variable dependencies of an existing variable according to a clone_get_equiv map and/or replacement variables that already exist within a FunctionGraph.

The latter is especially annoying, because you can’t simply make a FunctionGraph for the variable to be adjusted and then use that to perform the replacement; if the variables to be replaced are already in a FunctionGraph any such replacement will err-out saying “…these variables are already owned by another graph…”

inputs: list

List of input nodes.

outputs: list

List of output nodes. Everything between inputs and these outputs is the graph under consideration.

replacements: dict (optional)

A dictionary mapping existing nodes to their new ones. These values in this map will be used instead of newly generated clones. This dict is not altered.

memo: dict (optional)

A dictionary to update with the initial replacements and maps from any old-to-new nodes arising from an actual replacement. It serves the same role as replacements, but it is updated as elements are cloned.

clone_inputs: bool (optional)

If enabled, clone all the input nodes that aren’t mapped in replacements. These cloned nodes are mapped in memo, as well.

out: memo

Module contents