def __init__(self, ndoors=3):
        self.ndoors = ndoors
        def prob(prize, student, host, final):
            if prize == student:
                return 1./(self.ndoors**2) * 1. / (self.ndoors - 1)
            else:
                return 1./(self.ndoors**2) * 1. / (self.ndoors - 2)

        _sample_space = []
        for (prize, student, host) in product(range(1,self.ndoors+1),
                                              range(1,self.ndoors+1),
                                              range(1,self.ndoors+1)): 
            if host not in [prize, student]:
                _sample_space.append((prize, student, host, student))
        WeightedBox.__init__(self, dict([(v, prob(*v)) for v in
                                         _sample_space]))
Exemple #2
0
    def __init__(self, ndoors=3):
        self.ndoors = ndoors
        def prob(prize, student, host, final):
            if prize == student:
                return 1./(self.ndoors**2) * 1. / (self.ndoors - 1)
            else:
                return 1./(self.ndoors**2) * 1. / (self.ndoors - 2)

        _sample_space = []
        for (prize, student, host) in product(range(1,self.ndoors+1),
                                              range(1,self.ndoors+1),
                                              range(1,self.ndoors+1)): 
            if host not in [prize, student]:
                _sample_space.append((prize, student, host, student))
        WeightedBox.__init__(self, dict([(v, prob(*v)) for v in
                                         _sample_space]))
    def __init__(self, ndoors=3):
        self.ndoors = ndoors
        def prob(prize, student, host, final):
            if prize == student:
                return 1./(self.ndoors**2) * 1. / ((self.ndoors - 1) * (self.ndoors - 2))
            else:
                return 1./(self.ndoors**2) * 1. / ((self.ndoors - 2) * (self.ndoors - 2))

        _sample_space = []
        for (prize, student, host) in product(range(1,self.ndoors+1),
                                              range(1,self.ndoors+1),
                                              range(1,self.ndoors+1)): 
            if host not in [prize, student]:
                possible_values = set(range(1, self.ndoors+1)).difference( \
                    [host, student])
                for final in possible_values:
                    _sample_space.append((prize, student, host, final))
        WeightedBox.__init__(self, dict([(v, prob(*v)) for v in
                                         _sample_space]))
Exemple #4
0
    def __init__(self, ndoors=3):
        self.ndoors = ndoors
        def prob(prize, student, host, final):
            if prize == student:
                return 1./(self.ndoors**2) * 1. / ((self.ndoors - 1) * (self.ndoors - 2))
            else:
                return 1./(self.ndoors**2) * 1. / ((self.ndoors - 2) * (self.ndoors - 2))

        _sample_space = []
        for (prize, student, host) in product(range(1,self.ndoors+1),
                                              range(1,self.ndoors+1),
                                              range(1,self.ndoors+1)): 
            if host not in [prize, student]:
                possible_values = set(range(1, self.ndoors+1)).difference( \
                    [host, student])
                for final in possible_values:
                    _sample_space.append((prize, student, host, final))
        WeightedBox.__init__(self, dict([(v, prob(*v)) for v in
                                         _sample_space]))
Exemple #5
0
 def trial(self):
     WeightedBox.trial(self)
     self.car, self.student, self.host, self.final = np.array(
         self.outcome) - 1
     return self.outcome
Exemple #6
0
 def __init__(self, mass_function):
     WeightedBox.__init__(self, mass_function)
Exemple #7
0
 def conditional(self, event_spec):
     mass_fn = WeightedBox.conditional(self, event_spec).mass_function
     return conditional_switch(mass_fn)
 def trial(self):
     WeightedBox.trial(self)
     self.car, self.student, self.host, self.final = np.array(self.outcome)-1
     return self.outcome
 def __init__(self, mass_function):
     WeightedBox.__init__(self, mass_function)
 def conditional(self, event_spec):
     mass_fn = WeightedBox.conditional(self, event_spec).mass_function
     return conditional_switch(mass_fn)