Skip to main content
added this is a stochastic distribution as suggested by ssdecontrol
Source Link

I wonder whats the best way to visualize a formula (code for R would be nice, but the question is more general about what to visualize)

The formula (a stochastic distribution function) takes two arguments, a and b, and the result is mainly based on the three terms, relying on three variables and the two arguments of the function

I tried by plotting 2D (as shown below, but this does not help much), my next approach would be a 3d plot with x,y representing a and b, while z showing the result, colored by the relative value of the three variables for r/b/g... is this a good approch? Or is there a better way to get am impression how the variables have impact on the result?

a <- c(seq(0.1, 10, by=0.1)) 
b <- c(seq(0.1, 2, by=0.1)) 
var1 <- 0.1
var2 <- 0.1
var3 <- 0.1

myF <- function(a,b){ 
    if (a==0) return (0)
    if (b==0) return (0)
    term1 =  exp(1) ^ ( -1* ( var1 + var3 ) * a )   
    term2 =  exp(1) ^ ( -1* ( var2 + var3 ) * b )
    term3 =  exp(1) ^ ( -1*  var1 * a - var2 * b  - var3 * max(a ,b ))   
    return ( 1- term1 - term2 + term3) 
    }
par(mfrow=c(3,3))
for (var1 in c(1,2,3)) {  
    for (var2 in c(1,2,3)) {
        var3=0
        myFV <- Vectorize(myF)(a,b)
        main = substitute(   paste( "var1: ", var1, " var2: ", var2 , " var3: " , var3),    list(var1 = var1, var2 = var2, var3=var3))
        xlab = "a:0.1 .. 10, b: 0.1 .. 2"
        plot(myFV,  xlab=xlab, ylab="", main=main)
    }
}

I wonder whats the best way to visualize a formula (code for R would be nice, but the question is more general about what to visualize)

The formula takes two arguments, a and b, and the result is mainly based on the three terms, relying on three variables and the two arguments of the function

I tried by plotting 2D (as shown below, but this does not help much), my next approach would be a 3d plot with x,y representing a and b, while z showing the result, colored by the relative value of the three variables for r/b/g... is this a good approch? Or is there a better way to get am impression how the variables have impact on the result?

a <- c(seq(0.1, 10, by=0.1)) 
b <- c(seq(0.1, 2, by=0.1)) 
var1 <- 0.1
var2 <- 0.1
var3 <- 0.1

myF <- function(a,b){ 
    if (a==0) return (0)
    if (b==0) return (0)
    term1 =  exp(1) ^ ( -1* ( var1 + var3 ) * a )   
    term2 =  exp(1) ^ ( -1* ( var2 + var3 ) * b )
    term3 =  exp(1) ^ ( -1*  var1 * a - var2 * b  - var3 * max(a ,b ))   
    return ( 1- term1 - term2 + term3) 
    }
par(mfrow=c(3,3))
for (var1 in c(1,2,3)) {  
    for (var2 in c(1,2,3)) {
        var3=0
        myFV <- Vectorize(myF)(a,b)
        main = substitute(   paste( "var1: ", var1, " var2: ", var2 , " var3: " , var3),    list(var1 = var1, var2 = var2, var3=var3))
        xlab = "a:0.1 .. 10, b: 0.1 .. 2"
        plot(myFV,  xlab=xlab, ylab="", main=main)
    }
}

I wonder whats the best way to visualize a formula (code for R would be nice, but the question is more general about what to visualize)

The formula (a stochastic distribution function) takes two arguments, a and b, and the result is mainly based on the three terms, relying on three variables and the two arguments of the function

I tried by plotting 2D (as shown below, but this does not help much), my next approach would be a 3d plot with x,y representing a and b, while z showing the result, colored by the relative value of the three variables for r/b/g... is this a good approch? Or is there a better way to get am impression how the variables have impact on the result?

a <- c(seq(0.1, 10, by=0.1)) 
b <- c(seq(0.1, 2, by=0.1)) 
var1 <- 0.1
var2 <- 0.1
var3 <- 0.1

myF <- function(a,b){ 
    if (a==0) return (0)
    if (b==0) return (0)
    term1 =  exp(1) ^ ( -1* ( var1 + var3 ) * a )   
    term2 =  exp(1) ^ ( -1* ( var2 + var3 ) * b )
    term3 =  exp(1) ^ ( -1*  var1 * a - var2 * b  - var3 * max(a ,b ))   
    return ( 1- term1 - term2 + term3) 
    }
par(mfrow=c(3,3))
for (var1 in c(1,2,3)) {  
    for (var2 in c(1,2,3)) {
        var3=0
        myFV <- Vectorize(myF)(a,b)
        main = substitute(   paste( "var1: ", var1, " var2: ", var2 , " var3: " , var3),    list(var1 = var1, var2 = var2, var3=var3))
        xlab = "a:0.1 .. 10, b: 0.1 .. 2"
        plot(myFV,  xlab=xlab, ylab="", main=main)
    }
}
Source Link

How to visualize impact of variables on formula?

I wonder whats the best way to visualize a formula (code for R would be nice, but the question is more general about what to visualize)

The formula takes two arguments, a and b, and the result is mainly based on the three terms, relying on three variables and the two arguments of the function

I tried by plotting 2D (as shown below, but this does not help much), my next approach would be a 3d plot with x,y representing a and b, while z showing the result, colored by the relative value of the three variables for r/b/g... is this a good approch? Or is there a better way to get am impression how the variables have impact on the result?

a <- c(seq(0.1, 10, by=0.1)) 
b <- c(seq(0.1, 2, by=0.1)) 
var1 <- 0.1
var2 <- 0.1
var3 <- 0.1

myF <- function(a,b){ 
    if (a==0) return (0)
    if (b==0) return (0)
    term1 =  exp(1) ^ ( -1* ( var1 + var3 ) * a )   
    term2 =  exp(1) ^ ( -1* ( var2 + var3 ) * b )
    term3 =  exp(1) ^ ( -1*  var1 * a - var2 * b  - var3 * max(a ,b ))   
    return ( 1- term1 - term2 + term3) 
    }
par(mfrow=c(3,3))
for (var1 in c(1,2,3)) {  
    for (var2 in c(1,2,3)) {
        var3=0
        myFV <- Vectorize(myF)(a,b)
        main = substitute(   paste( "var1: ", var1, " var2: ", var2 , " var3: " , var3),    list(var1 = var1, var2 = var2, var3=var3))
        xlab = "a:0.1 .. 10, b: 0.1 .. 2"
        plot(myFV,  xlab=xlab, ylab="", main=main)
    }
}