This file is indexed.

/usr/lib/python3/dist-packages/pygal/stats.py is in python3-pygal 2.4.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from math import log, pi, sqrt


def erfinv(x, a=.147):
    """Approximation of the inverse error function
    https://en.wikipedia.org/wiki/Error_function
    #Approximation_with_elementary_functions
    """
    lnx = log(1 - x * x)
    part1 = (2 / (a * pi) + lnx / 2)
    part2 = lnx / a
    sgn = 1 if x > 0 else -1
    return sgn * sqrt(sqrt(part1 * part1 - part2) - part1)


def norm_ppf(x):
    if not 0 < x < 1:
        raise ValueError("Can't compute the percentage point for value %d" % x)
    return sqrt(2) * erfinv(2 * x - 1)


def ppf(x, n):
    try:
        from scipy import stats
    except ImportError:
        stats = None

    if stats:
        if n < 30:
            return stats.t.ppf(x, n)
        return stats.norm.ppf(x)
    else:
        if n < 30:
            # TODO: implement power series:
            # http://eprints.maths.ox.ac.uk/184/1/tdist.pdf
            raise ImportError(
                'You must have scipy installed to use t-student '
                'when sample_size is below 30')
        return norm_ppf(x)

# According to http://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/
# BS704_Confidence_Intervals/BS704_Confidence_Intervals_print.html


def confidence_interval_continuous(
        point_estimate, stddev, sample_size, confidence=.95, **kwargs):
    """Continuous confidence interval from sample size and standard error"""
    alpha = ppf((confidence + 1) / 2, sample_size - 1)

    margin = stddev / sqrt(sample_size)
    return (point_estimate - alpha * margin, point_estimate + alpha * margin)


def confidence_interval_dichotomous(
        point_estimate, sample_size, confidence=.95, bias=False,
        percentage=True, **kwargs):
    """Dichotomous confidence interval from sample size and maybe a bias"""
    alpha = ppf((confidence + 1) / 2, sample_size - 1)
    p = point_estimate
    if percentage:
        p /= 100

    margin = sqrt(p * (1 - p) / sample_size)
    if bias:
        margin += .5 / sample_size
    if percentage:
        margin *= 100

    return (point_estimate - alpha * margin, point_estimate + alpha * margin)


def confidence_interval_manual(point_estimate, low, high):
    return (low, high)