Generate distribution given percentile ranks

后端 未结 3 637
旧时难觅i
旧时难觅i 2021-01-07 15:21

I\'d like to generate a distribution in R given the following score and percentile ranks.

x <- 1:10
PercRank <- c(1, 7, 12, 23, 41, 62, 73, 80, 92, 99)         


        
3条回答
  •  星月不相逢
    2021-01-07 16:00

    i think you want the ecdf function, which is mentioned as the inverse of the quantile function on the ?quantile help page..

    # construct your vector containing the data
    PercRank <- c(1, 7, 12, 23, 41, 62, 73, 80, 92, 99)
    
    # construct an empirical cumulative distribution function
    # which is really just the `inverse` of `quantile
    Fn <- ( ecdf( PercRank ) )
    # note that the `ecdf` function returns a function itself.
    
    # calculate what percent of `PercRank` is below these integers..
    Fn( 0 )
    Fn( 1 )
    Fn( 2 )
    Fn( 3 )
    Fn( 6 )
    Fn( 7 )
    Fn( 8 )
    
    
    # re-construct your `x` vector using PercRank
    Fn( PercRank ) * 10
    

提交回复
热议问题