Esempio n. 1
0
def lpdf(rv, sample, **kwargs):
    """
    Return the probability (density) that random variable `rv`, returned by
    a call to one of the sampling routines of this class takes value `sample`
    """
    if not is_rv(rv):
        raise TypeError('rv not recognized as a random variable', rv)

    if is_raw_rv(rv):
        dist_name = rstreams.rv_dist_name(rv)
        pdf = rstreams.pdfs[dist_name]
        return pdf(rv.owner, sample, kwargs)
    else:
        #TODO: infer from the ancestors of v what distribution it
        #      has.
        raise NotImplementedError(rv)
Esempio n. 2
0
def normal_get_sigma(v):
    # look in uniform_sampler to see the positions of these things
    if v.owner and rv_dist_name(v) == "normal":
        return v.owner.inputs[3]
    raise TypeError
Esempio n. 3
0
def uniform_get_high(v):
    # look in uniform_sampler to see the positions of these things
    if v.owner and rv_dist_name(v) == "uniform":
        return v.owner.inputs[3]
    raise TypeError
Esempio n. 4
0
def qlognormal_get_round(v):
    # look in uniform_sampler to see the positions of these things
    if v.owner and rv_dist_name(v) == "quantized_lognormal":
        return v.owner.inputs[4]
    raise TypeError
Esempio n. 5
0
def normal_get_sigma(v):
    # look in uniform_sampler to see the positions of these things
    if rv_dist_name(v) == "normal":
        return v.owner.inputs[3]
    raise ValueError("v is not a normal draw", v)
Esempio n. 6
0
def uniform_get_high(v):
    # look in uniform_sampler to see the positions of these things
    if rv_dist_name(v) == "uniform":
        return v.owner.inputs[3]
    raise ValueError("v is not a uniform draw", v)
Esempio n. 7
0
def quantized_lognormal_get_round(v):
    # look in uniform_sampler to see the positions of these things
    if rv_dist_name(v) == "quantized_lognormal":
        return v.owner.inputs[4]
    raise ValueError("v is not a quantized_lognormal draw", v)
Esempio n. 8
0
def quantized_lognormal_get_sigma(v):
    # look in uniform_sampler to see the positions of these things
    if rv_dist_name(v) == 'quantized_lognormal':
        return v.owner.inputs[3]
    raise ValueError('v is not a quantized_lognormal draw', v)
Esempio n. 9
0
def lognormal_get_mu(v):
    # look in uniform_sampler to see the positions of these things
    if rv_dist_name(v) == 'lognormal':
        return v.owner.inputs[2]
    raise ValueError('v is not a lognormal draw', v)
Esempio n. 10
0
def uniform_get_low(v):
    # look in uniform_sampler to see the positions of these things
    if rv_dist_name(v) == 'uniform':
        return v.owner.inputs[2]
    raise ValueError('v is not a uniform draw', v)