예제 #1
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]))
예제 #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]))
예제 #3
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]))
예제 #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]))
예제 #5
0
 def __init__(self, mass_function):
     WeightedBox.__init__(self, mass_function)
예제 #6
0
 def __init__(self, mass_function):
     WeightedBox.__init__(self, mass_function)