예제 #1
0
def _build_custom_rv(distribution, sample_shape, value, name):
    """RandomVariable constructor with a dummy name argument."""
    # Program transformations (e.g., `make_log_joint_fn`) assume that
    # the traced constructor has `name` and `value` kwargs, enabling
    # them to override the value of an RV according to its name.
    # User-defined RVs inherit their name from the provided
    # distribution; this helper method exposes the name as a dummy kwarg
    # so that it's visible to program transformations.
    del name  # unused
    return RandomVariable(distribution=distribution,
                          sample_shape=sample_shape,
                          value=value)
예제 #2
0
    def func(*args, **kwargs):
        # pylint: disable=g-doc-args
        """Create a random variable for ${cls}.

    See ${cls} for more details.

    Returns:
      RandomVariable.

    #### Original Docstring for Distribution

    ${doc}
    """
        # pylint: enable=g-doc-args
        sample_shape = kwargs.pop('sample_shape', ())
        value = kwargs.pop('value', None)
        return RandomVariable(distribution=distribution_cls(*args, **kwargs),
                              sample_shape=sample_shape,
                              value=value)