Why is this detected as a virus?

Well… needed to remove AVG because this cpp code: 

double avg(double *T, int s1, int s2) //Calculates average within a range from s1 to s2
{
    int n = s2-s1+1; 
    int sum=0;//sum of elements
    for(int i=s1; i<=s2; i++)
    {
        sum+=T[i];
    }
    return sum/n;
}

is detected as Ransom_s.GB.
Because this function after removing AVG works fine for me, I don't consider installing it back, until you fix it.

Aleksander.
I understand your concern, In this case to analysis the issue I will request to send the analysis to below link to check the issue.
https://secure.avg.com/submit-sample
Thank you.