Exemplo n.º 1
0
    def __init__(self):
        """Initializes the cache.

        joint: map from (age, bucket) to frequency
        sequences: map from bucket to a list of sequences
        initial_rdt: sequence of (V0, rdt) pairs
        """
        self.joint = thinkbayes.Joint()
        self.sequences = {}
        self.initial_rdt = []
Exemplo n.º 2
0
def makeOneCauseMI(p=0.5, q=0.5):
    px=prob.MakePmfFromDict({"H":p, "L":1.0-p})
    joint = prob.Joint()
    for v1, p1 in px.Items():
        if v1 =="H":
            joint.Set((v1, "H"), p1*q)
            joint.Set((v1, "L"), p1*q)
        else:
            joint.Set((v1, "H"), 0.0)
            joint.Set((v1, "L"), p1*1.0)
    py=joint.Marginal(1)
    return px, py, joint
Exemplo n.º 3
0
    def GetDistAgeSize(self, size_thresh=MAXSIZE):
        """Gets the joint distribution of age and size.

        Map from (age, log size in cm) to log freq
        
        Returns: new Pmf object
        """
        joint = thinkbayes.Joint()

        for val, freq in self.joint.Items():
            age, bucket = val
            cm = BucketToCm(bucket)
            if cm > size_thresh:
                continue
            log_cm = math.log10(cm)
            joint.Set((age, log_cm), math.log(freq) * 10)

        return joint