analysis/randomB.R

randomB <- function(G,lB = 0.1,uB = 0.9,twoIntervals = 1)
# if twoIntervals == TRUE, lB and uB should be positive
# Copyright (c) 2012-2012  Jonas Peters [[email protected]]
# All rights reserved.  See the file COPYING for license terms.
{
    numCoeff <- sum(G)
    B <- t(G)
    if(numCoeff ==1)
    {
        coeffs <- sample(c(-1,1),size=numCoeff,0.5)^(twoIntervals) * runif(1,lB,uB)
    }
    else
    {
        coeffs <- diag(sample(c(-1,1),size=numCoeff,0.5)^(twoIntervals)) %*% runif(numCoeff,lB,uB)
    }
    B[B==1] <- coeffs
    return(B)
}
nicolagnecco/causalXtreme documentation built on Jan. 29, 2020, 5:50 p.m.