Skip to content

Instantly share code, notes, and snippets.

@Gormador
Gormador / percentileComputations.py
Last active August 7, 2018 14:42
Code for two different approaches of percentile computation.
##
# For both approaches, "sortedDensities" (given as arg "densitiesList" in the dichotomy-based solution)
# is a list of the reference dataset, from which are computed the corresponding percentile of each
# "density" of another dataset.
# The second function is ill-named, as it doens't return a percentile but the index of the "densitiesList" array
# used to compute the "density" percentile.
##
##
# Naive, brute-force approach.
@Gormador
Gormador / percentileComputations.py
Created August 7, 2018 14:28
Code for two different approaches of percentile computation.
##
# Naive, brute-force approach.
# You simply count how many values are smaller than the one for which you want to compute the percentile.
#
def getPercentileOfDensity(density):
nbInf = 0
for d in sortedDensities:
if d < density:
nbInf+=1
@Gormador
Gormador / percentileComputations.py
Created August 7, 2018 14:28
Code for two different approaches of percentile computation.
##
# Naive, brute-force approach.
# You simply count how many values are smaller than the one for which you want to compute the percentile.
#
def getPercentileOfDensity(density):
nbInf = 0
for d in sortedDensities:
if d < density:
nbInf+=1
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management