zoukankan      html  css  js  c++  java
  • 分位数和分位线(Quantiles and Percentiles)

    • 分位数有种积分(累积)的含义在。
    • 分位数(即将数据由低至高排列,小于该数的数据占总体的比例达到时最终落到的数):
      • 10%:3000元
      • 20%:5200元
      • 50%:20000元
      • 80%:41500元
      • 90%:50000元

    1. 分位数定义

    分位数还是序列中的数,只不过序列要首先进行排序;

    quantile initially assigns the sorted values in X to the (0.5/n), (1.5/n), …, ([n – 0.5]/n) quantiles. For example:

    ((1:n)-.5)/n

    n 表示序列的长度;

    • For a data vector of six elements such as {6, 3, 2, 10, 8, 1}, the sorted elements {1, 2, 3, 6, 8, 10} (先排序)respectively correspond to the (0.5/6), (1.5/6), (2.5/6), (3.5/6), (4.5/6), and (5.5/6) quantiles.
    • For a data vector of five elements such as {2, 10, 5, 9, 13}, the sorted elements {2, 5, 9, 10, 13} respectively correspond to the 0.1, 0.3, 0.5, 0.7, and 0.9 quantiles.

    2. 自定义函数

    function val = SpecialPercentile(arr, pct)
    
        len = length(arr);
        ind = floor(pct/100*len);                   % floor 取整,因为该数要作为索引
        newarr = sort(arr);                         % 排序,渐增排序;
        val = newarr(ind);
    
    end

    3. matlab 内置函数

    Y = prctile(X,p)
    rng('default'); % for reproducibility
    x = normrnd(5,2,1,10)
    x =
         6.0753    8.6678    0.4823    6.7243    5.6375    2.3846    4.1328   5.6852   12.1568   10.5389
    Y = prctile(x,42)
    Y =
        5.6709
  • 相关阅读:
    P3383 【模板】线性筛素数
    POJ2431-Expedition【优先队列+贪心】
    HDU1087
    HDU1029
    最小生成树之Kruskal算法
    AC自动机模板
    328闯关解析
    php可获取客户端信息
    $( ).focus()与$( )[0].focus()区别
    RegExp类型和text()方法
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9422104.html
Copyright © 2011-2022 走看看