Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Percentile Function

    I am trying to get a 90th percentile number out of a list of numbers.
    Example... Number List = 1,2,3,4,5,6,7,8,9,10,11 and the 90th percent number
    would be 10 Number List = 2,3,4,5,6,7,8,9,10,11,12 and the 90th percent number
    would be 11 Number List = 4,5,5,6,6 and the 90th percent number would be 6 But
    not sure how to do this... Excel has a function -> Percentile({1,2,3,4},0.3) =
    1.9 <- this is 30th percent though... I can't seem to figure out how to get CF
    to spit it out... Do I build a number list, and array or what... I am pulling
    my hair out - any help is appreciated... Merle

    Merle_Hanson Guest

  2. Similar Questions and Discussions

    1. #40509 [NEW]: key() function changed behaviour if global array is used within function
      From: alex dot killing at gmx dot de Operating system: MaxOsX/RedHat PHP version: 5.2.1 PHP Bug Type: Arrays related Bug...
    2. [PHP-DEV] named function arguments (was: Proposal: Dangling comma in function
      Christian Schneider wrote: Named parameters - i think is very good idea. I know i would use them. I'm really not sure about the correct...
    3. #25866 [Opn->Bgs]: Using error_reporting() function don't change output of phpinfo() function
      ID: 25866 Updated by: sniper@php.net Reported By: sfournier at dmsolutions dot ca -Status: Open +Status: ...
    4. note 33714 added to function.register-tick-function
      please can anyone help me to discover if this function can be used to make a chat ---- Manual Page --...
    5. note 33132 deleted from function.register-shutdown-function by sniper
      Note Submitter: markus@malkusch.de ---- I can't agree with nick at nickjoyce dot com. I use php 4.2.3 on linux and my shutdown function is...
  3. #2

    Default Re: Percentile Function

    I'm assuming that the definition of the 90th percentile is that number in a
    list that is greater than 90% of all numbers and less than 10% of all numbers.
    If this is correct, then sort your list , count the number of elements in the
    list, multiply the count by 0.9 and use the result in a ListGetAt statement.
    See code below.



    <CFSET stuff = "1,3,7,5,4,8,2,4,3,6,5,1,8,4">
    <CFSET stuff = ListSort(stuff, "Numeric", "Asc")>
    <CFSET count = ListLen(stuff)>
    <CFSET i = Round(count * 0.9)>
    <CFSET ninty = ListGetAt(stuff, i)>

    jdeline Guest

  4. #3

    Default Re: Percentile Function

    Close I think thanx... I'm trying different number lists... For example -
    12.2,14,33.4,3.7,8,6.5,4.75 is a list of 7 numbers... And your code gets me the
    number 14 as 90th %... When I do same code in excel - I get 21.76 as number...
    So not sure how to get that 21.76 number...

    Merle_Hanson Guest

  5. #4

    Default Re: Percentile Function

    There appear to be more than one definition of percentile. Mine is one of them; you can get more information about this wierdness at [url]http://cnx.rice.edu/content/m10805/latest/[/url].


    jdeline Guest

  6. #5

    Default Re: Percentile Function

    yes - that is where i started...
    I'm at a loss though... Part of me say ur solution is correct - but doing same numbers in Excel - relates there is a different number...

    Merle_Hanson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139