def noticeStimulus(self):
     '''
     Give each agent the opportunity to notice the future stimulus payment and
     mentally account for it in their market resources.
     '''
     if self.T_til_check > 0:
         self.T_til_check -= 1
     
     updaters = drawBernoulli(self.AgentCount, p=self.UpdatePrb, seed=self.RNG.randint(0,2**31-1))
     if self.T_til_check == 0:
         updaters = np.ones(self.AgentCount, dtype=bool)
     
     self.mNrmNow[updaters] += self.Stim_unnoticed[updaters]*self.StimLvl[updaters]/self.pLvlNow[updaters]*self.Rfree[0]**(-self.T_til_check)
     self.Stim_unnoticed[updaters] = False
Exemple #2
0
    def getAdjust(self):
        '''
        Sets the attribute AdjustNow as a boolean array of size AgentCount, indicating
        whether each agent is able to adjust their risky portfolio share this period.
        Uses the attribute AdjustPrb to draw from a Bernoulli distribution.
        
        Parameters
        ----------
        None

        Returns
        -------
        None
        '''
        self.AdjustNow = drawBernoulli(self.AgentCount,
                                       p=self.AdjustPrb,
                                       seed=self.RNG.randint(0, 2**31 - 1))
Exemple #3
0
    def getShocks(self):
        '''
        Determine which agents switch from employment to unemployment.  All unemployed agents remain
        unemployed until death.

        Parameters
        ----------
        None

        Returns
        -------
        None
        '''
        employed = self.eStateNow == 1.0
        N = int(np.sum(employed))
        newly_unemployed = drawBernoulli(N,p=self.UnempPrb,seed=self.RNG.randint(0,2**31-1))
        self.eStateNow[employed] = 1.0 - newly_unemployed
Exemple #4
0
 def test_drawBernoulli(self):
     self.assertEqual(simulation.drawBernoulli(1)[0], False)