summaryrefslogtreecommitdiffstats
path: root/R/distrib.R
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-03-31 15:40:24 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2017-03-31 15:40:24 -0400
commitf0653d4b0e7294a5665465951410c51c2daf93ca (patch)
tree91098bfafe7c077d17ba9ca7d00f4d240bd6f98a /R/distrib.R
parent6add5861120e1b34c386ded3409837a2bd33a939 (diff)
downloadlossdistrib-f0653d4b0e7294a5665465951410c51c2daf93ca.tar.gz
typos
Diffstat (limited to 'R/distrib.R')
-rw-r--r--R/distrib.R14
1 files changed, 4 insertions, 10 deletions
diff --git a/R/distrib.R b/R/distrib.R
index 8eb8c42..2b19aa6 100644
--- a/R/distrib.R
+++ b/R/distrib.R
@@ -78,11 +78,11 @@ convolve <- function(dist1, dist2) {
#' We compute the probability distribution of \eqn{S = \sum_{i=1}^n X_i}
#' where \eqn{X_i} is Bernouilli(\eqn{p_i}).
#' This uses the FFT, thus complexity is of order \eqn{O(n \log(n))},
-#' compared to \eqn{O(n^2)} for the recurvise algotithm.
+#' compared to \eqn{O(n^2)} for the recursive algorithm.
#' @param p Numeric vector, the vector of success probabilities
#' @return A vector such that \eqn{q_k=\Pr(S=k)}
lossdistrib.fft <- function(p) {
- ## haven't tested when p is not a poiwer of 2.
+ ## haven't tested when p is not a power of 2.
if(length(p) == 1){
c(1-p, p)
}else {
@@ -222,7 +222,7 @@ recovdist <- function(dp, pp, w, S, N){
#' @param w Numeric, vector of weights
#' @param S Numeric, vector of severities
#' @param N Integer, number of ticks in the grid
-#' @param defaultflab Logical, whether to return the loss or default distribution
+#' @param defaultflag Logical, whether to return the loss or default distribution
#' @return q Matrix of joint loss, recovery probability distribution
#' colSums(q) is the recovery distribution marginal
#' rowSums(q) is the loss distribution marginal
@@ -364,12 +364,6 @@ recovdistC <- function(dp, pp, w, S, N){
as.double(w), as.double(S), as.integer(N), q = double(N))$q
}
-lossdistC.joint <- function(p, w, S, N, defaultflag=FALSE){
- ## C version of lossdistrib.joint, roughly 20 times faster
- .C("lossdistrib_joint", as.double(p), as.integer(length(p)), as.double(w),
- as.double(S), as.integer(N), as.logical(defaultflag), q = matrix(0, N, N))$q
-}
-
lossdistC.jointZ <- function(dp, w, S, N, defaultflag = FALSE, rho, Z, wZ){
## N is the size of the grid
## dp is of size n.credits
@@ -385,7 +379,7 @@ lossdistC.jointZ <- function(dp, w, S, N, defaultflag = FALSE, rho, Z, wZ){
lossdistC.prepay.joint <- function(dp, pp, w, S, N, defaultflag=FALSE){
## C version of lossdist.prepay.joint
- r <- .C("lossdistrib_prepay_joint", as.double(dp), as.double(pp), as.integer(length(dp)),
+ r <- .C("lossdistrib_joint", as.double(dp), as.double(pp), as.integer(length(dp)),
as.double(w), as.double(S), as.integer(N), as.logical(defaultflag), q=matrix(0, N, N))$q
return(r)
}