How to detect a hot hatch in the form of numbers?

This is more of an algorithmic question, where they say that you have a picture that looks like 4 6 2 4 9 5 23 54 33 the last three digits are a hot series. I am wondering how this can be detected programmatically (or mathematically).

Right now I'm thinking of scanning data with a finite average let value of, say, 3 values. If the new value (23) is suddenly much higher than average, we mark the beginning of a possible band. The following figures should not deviate too much from him to consider the hot streak to continue.

Does this sound like an effective approach? Are there any algorithms that already exist for such tasks?

+4
source share
3 answers

Good. I gave this snapshot, but before starting, I have to say that it is not based on any algorithm (at least: I do not know based on the existing algorithm), and there are some drawbacks (it does not take into account for negative numbers / zero), and there are probably many edge cases.

To find the distance between two numbers, to determine if they are similar or not, I found this simple formula :

Percentage difference = (L - S) / S

where L is the largest and S is the smallest.

First of all, the conclusion is for 5 random sequences of 50 values ​​between 1 and 40:

7 14 34 13 4 1 3 34 10 29 25 32 28 39 14 32 37 30 21 27 28 27 26 25 27 34 15 36 3 29 32 35 8 32 20 5 30 4 17 16 27 35 7 34 7 37 14 31 38 23 
Possible hot streak (treshold 0,95): 27 - 28 - 27
Possible hot streak (treshold 0,95): 28 - 27 - 26
Possible hot streak (treshold 0,95): 27 - 26 - 25

9 16 17 3 11 19 28 10 25 10 25 6 31 21 37 29 24 35 20 9 2 34 14 6 1 33 21 31 19 30 20 23 38 19 21 16 19 6 21 1 17 20 18 7 30 22 4 26 37 17 
Possible hot streak (treshold 0,8): 17 - 20 - 18

14 18 12 30 22 15 3 12 3 18 38 36 31 35 30 3 8 13 39 21 11 19 14 19 31 22 16 7 15 19 29 34 33 2 16 3 12 8 37 6 14 7 4 4 2 21 29 22 17 27 
Possible hot streak (treshold 0,8): 38 - 36 - 31
Possible hot streak (treshold 0,8): 36 - 31 - 35
Possible hot streak (treshold 0,8): 31 - 35 - 30
Possible hot streak (treshold 0,8): 29 - 34 - 33

14 31 26 16 6 35 5 32 38 39 38 35 36 24 29 4 3 29 20 28 31 39 15 34 8 4 15 11 18 11 32 34 30 28 5 38 9 17 35 21 37 19 9 37 8 18 11 20 14 37 
Possible hot streak (treshold 0,95): 38 - 39 - 38

18 39 3 29 36 14 17 32 9 3 20 33 15 28 8 5 6 9 19 30 35 25 34 38 30 13 30 17 27 29 33 35 36 20 33 33 31 2 31 30 21 16 9 33 2 5 4 21 30 3 
Possible hot streak (treshold 0,9): 33 - 35 - 36
Possible hot streak (treshold 0,9): 33 - 33 - 31

, , : , , 3, , . , , . , 0,05 (: ) .

, . - -, 3 , . .

, , , , , ( ).

, , , , , .

, ( , ) - , .

3 2 0,5, 30 29 0,03, . , .

:

void Main()
{
    for(int i = 0; i < 5; i++){
        var list = GetList();
        DisplayList(list);
        GetHotStreaks(list);
    }
}

private static Random rand = new Random();

private List<int> GetList(){
    var list = new List<int>();

    for(int i = 0; i < 50; i++){
        list.Add(rand.Next(1, 40));
    }
    return list;
}

private void DisplayList(List<int> list){
    for(int i = 0; i < list.Count; i++){
        Console.Write(list[i] + " ");
    }
    Console.WriteLine();
}

private void GetHotStreaks(List<int> list){
    double treshold = 0.95;
    bool found = false;

    while(treshold > 0.0){
        for(int i = 0; i < list.Count - 2; i++){
            if(AreWithinRange(list[i], list[i + 1], list[i + 2], treshold)){
                Console.WriteLine (string.Format("Possible hot streak (treshold {0}): {1} - {2} - {3}", treshold, list[i], list[i + 1], list[i + 2]));
                found = true;
            }
        }

        if(found){
            Console.WriteLine ();
            return;
        }

        treshold -= 0.05;
    }   
}

private bool AreWithinRange(int val1, int val2, int val3, double treshold){
    return AreWithinRange(val1, val2, treshold) && AreWithinRange(val2, val3, treshold);
}

// http://www.oracle.com/webfolder/technetwork/data-quality/edqhelp/Content/processor_library/matching/comparisons/percent_difference.htm
private bool AreWithinRange(int val1, int val2, double treshold){
    double max = Math.Max(val1, val2);
    double min = Math.Min(val1, val2);
    double pd = (max - min) / min;

    //Console.WriteLine ("Values: val1: {0}\t val2: {1}\t PD: {2}\t T: {3}", val1, val2, pd, treshold);
    return pd <= 1 - treshold;
}
+4

, FIR-, - .

( ).

, ( ). FIR ( ) , .

, , , .

FIR , , , usecase.

, , , .

0

, , , (, , ).

n . , , .

EMA SMA , , , 2, .

, , . , .

, .

I would suggest a relative strength index above 70, indicating a hot band.

0
source

Source: https://habr.com/ru/post/1529490/


All Articles