예제 #1
0
파일: rv.py 프로젝트: phucson/MonteTheano
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)
예제 #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
예제 #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
예제 #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
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #11
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)
예제 #12
0
def lognormal_get_sigma(v):
    # look in uniform_sampler to see the positions of these things
    if rv_dist_name(v) == 'lognormal':
        return v.owner.inputs[3]
    raise ValueError('v is not a lognormal draw', v)
예제 #13
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)