Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C climix
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 53
    • Issues 53
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • climix
  • climix
  • Issues
  • #178

Closed
Open
Created Mar 10, 2020 by Lars Bärring@a001257Developer

percentile method

ETCCDI is rather specific when it comes to percentiles, cf. [1]. Mention #75 (closed), #148 (closed), #175

The specified method, Hyndman & Fan no. 8, is available in scipy.stats.mstats.mquantiles. It would be useful to make use of it if not too detrimental to timing. So I did a very quick test (patterned after some Stack Exchange answer):


setup = '''
import random
import numpy as np
import scipy.stats.mstats as mstats

random.seed('slartibartfast')
s = [random.random() for i in range(1000)]
p = 35
third = 1./3. # this particular value gives H&F#8
numper = lambda x: np.percentile(x, p)
statper = lambda x: mstats.mquantiles(x, [p/100.], alphap=third, betap=third)
'''

print(min(timeit.Timer('x=s[:]; statper(x)', setup=setup).repeat(7, 1000)))
# 2.9134851020062342

print(min(timeit.Timer('x=s[:]; numper(x)', setup=setup).repeat(7, 1000)))
# 0.1574339639628306

This does not look overly promising, so I suggest that we leave this for now. Let's see what they might come up with over at numpy, cf. [1]

[1] Wiki page

Edited Mar 13, 2020 by Lars Bärring
Assignee
Assign to
Time tracking