Created
April 7, 2019 00:54
-
-
Save baogorek/446466133f9e8eb55e34bd8af61e0b74 to your computer and use it in GitHub Desktop.
This file contains 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
get_perf_params <- function(world_record_perf, able_bodied_perf, limit, | |
type = "running") { | |
# sum of squares around fixed point | |
rss <- function(a, b, world_record_perf, able_bodied_perf, limit) { | |
(1000 - b * log(a / (world_record_perf - limit))) ** 2 + | |
(0 - b * log(a / (able_bodied_perf - limit))) ** 2 | |
} | |
stopifnot(type %in% c("running", "jumping")) | |
a_starting <- ifelse(type == "running", 5, -5) | |
b_starting <- 100 | |
optim_results <- optim(c(a_starting, b_starting), | |
function(params) rss(params[1], params[2], | |
world_record_perf, | |
able_bodied_perf, limit)) | |
list(a = optim_results$par[1], b = optim_results$par[2], limit = limit, | |
optim_results = optim_results) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment