+ Reply to Thread
Results 1 to 4 of 4

Percentile --> how to?

Hybrid View

  1. #1
    BHARATH RAJAMANI
    Guest

    Percentile --> how to?

    Hi

    I have 5mio currency values in an unsorted VBA array. I need to find the
    99.99th percentile highest value without writing the array to a spreadsheet
    and using the worksheetfuntion.percentile

    Any ideas? TIA!!

    Rgds,
    BR

    --
    Capital Markets
    GE Capital, London

  2. #2
    Bernie Deitrick
    Guest

    Re: Percentile --> how to?

    BR,

    You can use

    MyVal = Application.worksheetfuntion.percentile(Array, 0.99)

    within VBA, without writing the array to the sheet.

    HTH,
    Bernie
    MS Excel MVP


    "BHARATH RAJAMANI" <BHARATHRAJAMANI@discussions.microsoft.com> wrote in message
    news:12B5EEF5-A073-48E3-BF82-E768C720E58B@microsoft.com...
    > Hi
    >
    > I have 5mio currency values in an unsorted VBA array. I need to find the
    > 99.99th percentile highest value without writing the array to a spreadsheet
    > and using the worksheetfuntion.percentile
    >
    > Any ideas? TIA!!
    >
    > Rgds,
    > BR
    >
    > --
    > Capital Markets
    > GE Capital, London




  3. #3
    BHARATH RAJAMANI
    Guest

    Re: Percentile --> how to?

    Bernie, Thx for the tip. It helps a bit, but I still have a problem with
    large datasets. This works well for small array sizes but not for large
    arrays. I get a type mismatch error. Here's my macro -

    'Macro

    Dim EL as Double
    Dim EL_99 as double
    Dim NetLosses() As Double
    '... Read array size = TotalScenarios = values from 250,000 to 5,000,000
    ReDim NetLosses(TotalScenarios) As Double
    '...
    For ctr1 = 0 to TotalScenarios - 1
    NetLosses(ctr1) = Ccur(1234567.89) 'Populate array with some value
    next ctr1

    'Type mismatch error here for large array sizes, works well for small array
    sizes
    EL = CDbl(Application.WorksheetFunction.Average(NetLosses()))
    'Type mismatch error for large array sizes, works well for small array sizes
    EL_99 = Application.WorksheetFunction.Percentile(NetLosses(), 0.9999)


    TIA!!

    Rgds,
    BR


    --
    Capital Markets
    GE Capital, London


    "Bernie Deitrick" wrote:

    > BR,
    >
    > You can use
    >
    > MyVal = Application.worksheetfuntion.percentile(Array, 0.99)
    >
    > within VBA, without writing the array to the sheet.
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    >
    > "BHARATH RAJAMANI" <BHARATHRAJAMANI@discussions.microsoft.com> wrote in message
    > news:12B5EEF5-A073-48E3-BF82-E768C720E58B@microsoft.com...
    > > Hi
    > >
    > > I have 5mio currency values in an unsorted VBA array. I need to find the
    > > 99.99th percentile highest value without writing the array to a spreadsheet
    > > and using the worksheetfuntion.percentile
    > >
    > > Any ideas? TIA!!
    > >
    > > Rgds,
    > > BR
    > >
    > > --
    > > Capital Markets
    > > GE Capital, London

    >
    >
    >


  4. #4
    Bharath Rajamani
    Guest

    Re: Percentile --> how to?


    Ref: From the Help menu on using the Percentile function:

    If the array has more than 8,191 values then it will not work. I guess this
    resolves the Q on why worksheetfunction.percentile returns errors with arrays
    of 250k to 1mio values


    Rgds,
    BR




    PERCENTILE
    See Also

    Returns the k-th percentile of values in a range. You can use this function
    to establish a threshold of acceptance. For example, you can decide to
    examine candidates who score above the 90th percentile.

    Syntax

    PERCENTILE(array,k)

    Array is the array or range of data that defines relative standing.

    K is the percentile value in the range 0..1, inclusive.

    Remarks

    If array is empty or contains more than 8,191 data points, PERCENTILE
    returns the #NUM! error value.


    If k is nonnumeric, PERCENTILE returns the #VALUE! error value.


    If k is < 0 or if k > 1, PERCENTILE returns the #NUM! error value.


    If k is not a multiple of 1/(n - 1), PERCENTILE interpolates to determine
    the value at the kth percentile.

    Example

    PERCENTILE({1,2,3,4},0.3) equals 1.9





    "Bernie Deitrick" wrote:

    > BR,
    >
    > You can use
    >
    > MyVal = Application.worksheetfuntion.percentile(Array, 0.99)
    >
    > within VBA, without writing the array to the sheet.
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    >
    > "BHARATH RAJAMANI" <BHARATHRAJAMANI@discussions.microsoft.com> wrote in message
    > news:12B5EEF5-A073-48E3-BF82-E768C720E58B@microsoft.com...
    > > Hi
    > >
    > > I have 5mio currency values in an unsorted VBA array. I need to find the
    > > 99.99th percentile highest value without writing the array to a spreadsheet
    > > and using the worksheetfuntion.percentile
    > >
    > > Any ideas? TIA!!
    > >
    > > Rgds,
    > > BR
    > >
    > > --
    > > Capital Markets
    > > GE Capital, London

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1