| 1 | ############################################################################# |
|---|
| 2 | # Auteur(e)s : F. Hourdin |
|---|
| 3 | # Function to convert [-1,1] LHC to above scale |
|---|
| 4 | ############################################################################# |
|---|
| 5 | |
|---|
| 6 | # 2. Function to convert [-1,1] LHC to above scale |
|---|
| 7 | DesignConvert <- function(Xconts){ |
|---|
| 8 | conversion <- function(anX,lows,highs){ |
|---|
| 9 | ((anX+1)/2)*(highs-lows) +lows |
|---|
| 10 | } |
|---|
| 11 | param.lows.log <- param.lows |
|---|
| 12 | param.highs.log <- param.highs |
|---|
| 13 | param.lows.log[which.logs] <- log10(param.lows[which.logs]) |
|---|
| 14 | param.highs.log[which.logs] <- log10(param.highs[which.logs]) |
|---|
| 15 | tX <- sapply(1:length(param.lows), function(i) conversion(Xconts[,i],param.lows.log[i],param.highs.log[i])) |
|---|
| 16 | tX[,which.logs] <- 10^tX[,which.logs] |
|---|
| 17 | tX <- as.data.frame(tX) |
|---|
| 18 | names(tX) <- param.names |
|---|
| 19 | tX |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | #3. Function to convert [above scale to [-1, 1] |
|---|
| 23 | DesignantiConvert <- function (Xconts){ |
|---|
| 24 | anticonversion <- function(newX,lows,highs){ |
|---|
| 25 | 2*((newX-lows)/(highs-lows))-1 |
|---|
| 26 | } |
|---|
| 27 | param.lows.log <- param.lows |
|---|
| 28 | param.highs.log <- param.highs |
|---|
| 29 | param.lows.log[which.logs] <- log10(param.lows[which.logs]) |
|---|
| 30 | param.highs.log[which.logs] <- log10(param.highs[which.logs]) |
|---|
| 31 | Xconts[,which.logs] <- log10(Xconts[,which.logs]) |
|---|
| 32 | tX <- sapply(1:length(param.lows), function(i) anticonversion(Xconts[,i],param.lows.log[i],param.highs.log[i])) |
|---|
| 33 | tX <- as.data.frame(tX) |
|---|
| 34 | names(tX) <- param.names |
|---|
| 35 | tX |
|---|
| 36 | } |
|---|
| 37 | DesignantiConvert1D <- function (Xconts){ |
|---|
| 38 | anticonversion <- function(newX,lows,highs){ |
|---|
| 39 | 2*((newX-lows)/(highs-lows))-1 |
|---|
| 40 | } |
|---|
| 41 | param.lows.log <- param.lows |
|---|
| 42 | param.highs.log <- param.highs |
|---|
| 43 | param.lows.log[which.logs] <- log10(param.lows[which.logs]) |
|---|
| 44 | param.highs.log[which.logs] <- log10(param.highs[which.logs]) |
|---|
| 45 | Xconts[which.logs] <- log10(Xconts[which.logs]) |
|---|
| 46 | tX <- sapply(1:length(param.lows), function(i) anticonversion(Xconts[i],param.lows.log[i],param.highs.log[i])) |
|---|
| 47 | tX <- as.data.frame(tX) |
|---|
| 48 | tX |
|---|
| 49 | } |
|---|