Skip to content

Instantly share code, notes, and snippets.

@uncletammy
Created December 9, 2014 18:40
Show Gist options
  • Save uncletammy/9a726cab26c343529efb to your computer and use it in GitHub Desktop.
Save uncletammy/9a726cab26c343529efb to your computer and use it in GitHub Desktop.
Problem with current return models for switching to geometric mean calculations

Example return Record

{ product: 1,
    index: null,
    category: null,
    type: 'monthly',
    year: 2007,
    month: 8,
    day: null,
    value: 0.27992,
    id: 1,
    createdAt: Tue Oct 21 2014 10:18:01 GMT-0500 (CDT),
    updatedAt: Tue Oct 21 2014 10:18:01 GMT-0500 (CDT) }

The problem is, getAAR should accept an array of "share price" values in USD. These are always positive. Currently it accepts an array of "percentage change in value from current month".

With the current state of our "return" records.

  • each element in the arguments array is the 'value' field of one months return record.
  • to evaluate a 3 year period, getAAR would get 12*3 data points.

Example output by our existing Arithmetic Mean calculator.

getAAR([4,1,-1,2]) ~ 6/2 = 3

Example output by a hypothetical Geometric Mean calculator

getAAR([4,1,-1,2]) ~ 4thRoot(41-1*2) ~ 4thRoot(-8) = NaN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment