How to use the statistics.median_high function in statistics

To help you get started, we’ve selected a few statistics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lschoe / mpyc / tests / test_statistics.py View on Github external
def test_secint(self):
        secint = mpc.SecInt()
        y = [1, 3, -2, 3, 1, -2, -2, 4] * 5
        random.shuffle(y)
        x = list(map(secint, y))
        self.assertEqual(mpc.run(mpc.output(mean(x))), round(statistics.mean(y)))
        self.assertEqual(mpc.run(mpc.output(variance(x))), round(statistics.variance(y)))
        self.assertEqual(mpc.run(mpc.output(variance(x, mean(x)))), round(statistics.variance(y)))
        self.assertEqual(mpc.run(mpc.output(stdev(x))), round(statistics.stdev(y)))
        self.assertEqual(mpc.run(mpc.output(pvariance(x))), round(statistics.pvariance(y)))
        self.assertEqual(mpc.run(mpc.output(pstdev(x))), round(statistics.pstdev(y)))
        self.assertEqual(mpc.run(mpc.output(mode(x))), round(statistics.mode(y)))
        self.assertEqual(mpc.run(mpc.output(median(x))), round(statistics.median(y)))
        self.assertEqual(mpc.run(mpc.output(median_low(x))), round(statistics.median_low(y)))
        self.assertEqual(mpc.run(mpc.output(median_high(x))), round(statistics.median_high(y)))
github sglebs / srccheck / utilities / csvkaloi.py View on Github external
# Publishing in SONAR: http://docs.codehaus.org/pages/viewpage.action?pageId=229743270

import datetime
import json
import os.path
import statistics
import sys
import csv
from docopt import docopt

from utilities import VERSION

STATS_LAMBDAS = {"AVG": statistics.mean,
                 "MEDIAN": statistics.median,
                 "MEDIANHIGH": statistics.median_high,
                 "MEDIANLOW": statistics.median_low,
                 "MEDIANGROUPED": statistics.median_grouped,
                 "MODE": statistics.mode,
                 "STDEV": statistics.pstdev,
                 "VARIANCE": statistics.pvariance}

def metric_name_for_sorting(metric_name):
    if ":" not in metric_name:
        return metric_name
    else:
        parts = metric_name.split(":")
        return parts[-1] + parts[0]

def process_csv_metrics (cmdline_arguments, max_values_allowed_by_metric):
    violation_count = 0
    highest_values_found_by_metric = {}
github DUanalytics / pyAnalytics / 45-stats1 / stats_median.py View on Github external
#Topic ----
# importing the statistics module 
import statistics 
#%%Median is often referred to as the robust measure of central location and is less affected by the presence of outliers in data.
#statistics module in Python allows three options to deal with median / middle elements in a data set, which are median(), median_low() and median_high().
#The low median is always a member of the data set. When the number of data points is odd, the middle value is returned. When it is even, the smaller of the two middle values is returned. 
#%%%
# simple list of a set of integers 
set1 = [1, 3, 3, 4, 5, 7] 
set1
# Note: low median will always be  a member of the data-set. 
# Print low median of the data-set 
print("Low median of the data-set is % s "   % (statistics.median_low(set1))) 
# lie within the data-set 
print("Median of the set is % s"       % (statistics.median(set1))) 
print("Low median of the data-set is % s "   % (statistics.median_high(set1))) 
#%%%
github saltstack / salt / salt / thorium / calc.py View on Github external
sum = sum + val
        return sum

    def opmul(vals):
        prod = 0
        for val in vals:
            prod = prod * val
        return prod

    ops = {
        'add': opadd,
        'mul': opmul,
        'mean': statistics.mean,
        'median': statistics.median,
        'median_low': statistics.median_low,
        'median_high': statistics.median_high,
        'median_grouped': statistics.median_grouped,
        'mode': statistics.mode,
    }

    count = 0
    vals = []
    __reg__[name]['val'].reverse()
    for regitem in __reg__[name]['val']:
        count += 1
        if count > num:
            break
        if ref is None:
            vals.append(regitem)
        else:
            vals.append(regitem[ref])
github joosthoeks / jhTAlib / jhtalib / statistic_functions / statistic_functions.py View on Github external
def MEDIAN_HIGH(df, n, price='Close'):
    """
    High median of data
    """
    median_high_list = []
    i = 0
    if n == len(df[price]):
        start = None
        while i < len(df[price]):
            if df[price][i] != df[price][i]:
                median_high = float('NaN')
            else:
                if start is None:
                    start = i
                end = i + 1
                median_high = statistics.median_high(df[price][start:end])
            median_high_list.append(median_high)
            i += 1
    else:
        while i < len(df[price]):
            if i + 1 < n:
                median_high = float('NaN')
            else:
                start = i + 1 - n
                end = i + 1
                median_high = statistics.median_high(df[price][start:end])
            median_high_list.append(median_high)
            i += 1
    return median_high_list
github MSeifert04 / iteration_utilities / src / iteration_utilities / _classes.py View on Github external
def get_median_high(self):
        """See :py:func:`statistics.median_high`.

        Examples
        --------
        >>> from iteration_utilities import Iterable
        >>> Iterable(range(10)).get_median_high()
        5
        """
        return self._get_iter(statistics.median_high, 0)
github sk89q / plumeria / orchard / stats.py View on Github external
def median_high(text):
    """
    Finds the high median of a space-separated list of numbers.

    Example::

        /median high 33 54 43 65 43 62
    """
    return format_output(statistics.median_high(parse_numeric_list(text)))
github sglebs / srccheck / utilities / srccheck.py View on Github external
import datetime
import json
import os.path
import statistics
import sys

from docopt import docopt

from utilities import VERSION
from utilities.utils import stream_of_entity_with_metric, save_histogram, save_csv, \
    save_kiviat_with_values_and_thresholds, \
    post_metrics_to_sonar, load_metrics_thresholds, insert_understand_in_path

STATS_LAMBDAS = {"AVG": statistics.mean,
                 "MEDIAN": statistics.median,
                 "MEDIANHIGH": statistics.median_high,
                 "MEDIANLOW": statistics.median_low,
                 "MEDIANGROUPED": statistics.median_grouped,
                 "MODE": statistics.mode,
                 "STDEV": statistics.pstdev,
                 "VARIANCE": statistics.pvariance}

class DummyEntity:
    def longname(self):
        return ""

def _print_routine_violation(routine, metric_name, metric_value, container_file=None):
    print("%s\t%s\t%s%s" % (metric_name, metric_value, routine.longname(),
                            "" if container_file == None else "\t(in %s)" % container_file.longname()))

def _print_file_violation(file, metric_name, metric_value, container_file=None):
    print("%s\t%s\t%s " % (metric_name, metric_value, file.longname()))
github joosthoeks / jhTAlib / jhtalib / statistic_functions / statistic_functions.py View on Github external
median_high = float('NaN')
            else:
                if start is None:
                    start = i
                end = i + 1
                median_high = statistics.median_high(df[price][start:end])
            median_high_list.append(median_high)
            i += 1
    else:
        while i < len(df[price]):
            if i + 1 < n:
                median_high = float('NaN')
            else:
                start = i + 1 - n
                end = i + 1
                median_high = statistics.median_high(df[price][start:end])
            median_high_list.append(median_high)
            i += 1
    return median_high_list