コード例 #1
0
ファイル: test_detector.py プロジェクト: darth10/stewie
def test_detector_should_be_able_to_calculate_probability():
    '''
    This probability mathematics was extracted from:
    http://s3.amazonaws.com/mlclass-resources/docs/slides/Lecture15.pdf

    >>> 1/(math.sqrt(math.pi * 2) * 20) * math.exp(-0.5)
    0.01209853622595717
    '''
    current_metric = 80
    avg_of_metric = 100
    variance = 400

    detector = Detector()

    assert round(0.01209853622595717 -
                detector.calculate_probability(current_metric, avg_of_metric, variance), 5) == 0
コード例 #2
0
ファイル: test_detector.py プロジェクト: darth10/stewie
def test_detector_should_be_able_to_calculate_probability_with_zero_variance():
    detector = Detector()
    assert 1 == detector.calculate_probability(1, 1, 0)