summaryrefslogtreecommitdiffstats
path: root/tests/testthat/test_lossdistrib.R
blob: 074cbf2208bf49a3450d0db8f172b2a103ad3ec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(lossdistrib)
p <- runif(1000)
S <- runif(1000)
issuer.weights <- rep(1/1000,1000)

run1 <- system.time(for(i in 1:1000){
    lossdistC(p, issuer.weights, S, 301)
})
cat("simple lossdist", run1["elapsed"], "\n")

S <- matrix(runif(1000*500), 1000, 500)
rho <- rep(0.45, 1000)
temp <- GHquad(500)
Z <- temp$Z
w <- temp$w

test <- lossdistCZ(p, issuer.weights, S, 301, FALSE, rho, Z)
p <- matrix(runif(100*25), 100, 25)
issuer.weights <- rep(1/100, 100)
S <- runif(100)

cat("I'm here")
rho <- rep(0.45, 100)
test <- BClossdistC(p, issuer.weights, 1-S, rho, temp$Z, temp$w)
# the blas function should be roughly twice as fast
cat("blas lossdist", run2["elapsed"], "\n")