Created
November 23, 2025 00:15
-
-
Save abikoushi/7a470de6d1f1aede14073b105fa09e48 to your computer and use it in GitHub Desktop.
draw utility (or expectation) function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ut <- function(x,alpha,beta,lambda){ | |
| ifelse(x>0, x^alpha, -lambda*((-x)^beta)) | |
| } | |
| params <- list( | |
| list(alpha=1,beta=1,lambda=1), | |
| list(alpha=1,beta=1,lambda=2), | |
| list(alpha=1/2,beta=1/2,lambda=2), | |
| list(alpha=2,beta=2,lambda=1) | |
| ) | |
| png("draw_u.png") | |
| par(mfrow =c(2,2)) | |
| for(i in 1:4){ | |
| with(params[[i]], curve(Ut(x,alpha,beta,lambda), -2,2, main=paste("scenario", i), ylab="U")) | |
| } | |
| dev.off() | |
| with(params[[1]], 0.5*Ut(1,alpha,beta,lambda)+0.5*Ut(-1,alpha,beta,lambda)) | |
| with(params[[2]], 0.5*Ut(1,alpha,beta,lambda)+0.5*Ut(-1,alpha,beta,lambda)) | |
| with(params[[3]], 0.5*Ut(1,alpha,beta,lambda)+0.5*Ut(-1,alpha,beta,lambda)) | |
| with(params[[4]], 0.5*Ut(1,alpha,beta,lambda)+0.5*Ut(-1,alpha,beta,lambda)) | |
| with(params[[1]], 0.5*Ut(2,alpha,beta,lambda)+0.5*Ut(0,alpha,beta,lambda)) | |
| with(params[[2]], 0.5*Ut(2,alpha,beta,lambda)+0.5*Ut(0,alpha,beta,lambda)) | |
| with(params[[3]], 0.5*Ut(2,alpha,beta,lambda)+0.5*Ut(0,alpha,beta,lambda)) | |
| with(params[[4]], 0.5*Ut(2,alpha,beta,lambda)+0.5*Ut(0,alpha,beta,lambda)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment