Search code examples
rdistributioncurve

how to generate curves of different curvature connceting 0 and 1?


I know this is mores statistical than programming question, but I would like a solution in R if possible. How can I generate a set of concave and convex curves of different curvature connecting 0 and 1 as shown in the example below:

enter image description here


Solution

  • You could use pbeta to plot the CDF of the beta distribution for different shape parameters

    shape1 <- c(4, 3, 2, 1, 1, 1, 1)
    shape2 <- c(1, 1, 1, 1, 2, 3, 4)
    x <- seq(0, 1, length.out = 100)
    
    library(tidyverse)
    map2_dfc(shape1, shape2, ~pbeta(x, .x, .y)) %>%
        bind_cols(x = x) %>%
        gather(key, y, -x) %>%
        ggplot(aes(x, y, group = key)) +
        geom_line()
    

    enter image description here