Esempio n. 1
0
    def test_defaultProcessor_allDefaults(self):

        gc = PysparseGaussianCopula(self.p)

        gc.thresholds = np.zeros(4)
        gc.thresholds += 100.0
        num_runs = 10
        corrValues = np.zeros(shape=(3, num_runs))

        defaults = defaultdict(int)
        gc.defaultProcessor(defaults, corrValues)
        self.assertEquals(defaults[0], 0)
        self.assertEquals(defaults[1], 0)
        self.assertEquals(defaults[2], 0)
        self.assertEquals(defaults[3], 0)
        self.assertEquals(defaults[4], 10)
Esempio n. 2
0
    def test_defaultProcessor_thirdIssuerDefaultsAllTheTime(self):

        gc = PysparseGaussianCopula(self.p)
        # need to make sure because of issuer set
        gc.asset_issuer_map = [0,1,2,0]

        gc.thresholds = np.zeros(4)
        num_runs = 10
        corrValues = np.zeros(shape=(3, num_runs))
        corrValues[2, :] -= 1.0 # issuer 1 will default all the time

        defaults = defaultdict(int)
        gc.defaultProcessor(defaults, corrValues)
        self.assertEquals(defaults[0], 0)
        self.assertEquals(defaults[1], 10)
        self.assertEquals(defaults[2], 0)
        self.assertEquals(defaults[3], 0)
        self.assertEquals(defaults[4], 0)
Esempio n. 3
0
    def test_defaultProcessor_firstIssuerDefaultsNotAllTheTime(self):

        gc = PysparseGaussianCopula(self.p)
        # need to make sure because of issuer set
        gc.asset_issuer_map = [0,1,2,0]

        gc.thresholds = np.zeros(4)
        num_runs = 10
        corrValues = np.zeros(shape=(3, num_runs))
        corrValues[0, :] = np.linspace(-5.0, 4.0, num_runs)

        defaults = defaultdict(int)
        gc.defaultProcessor(defaults, corrValues)
        self.assertEquals(defaults[0], 5)
        self.assertEquals(defaults[1], 0)
        self.assertEquals(defaults[2], 5) # two assets are linked to issuer 0
        self.assertEquals(defaults[3], 0)
        self.assertEquals(defaults[4], 0)