[GRASS5] v.univar

Radim Blazek blazek at itc.it
Fri Jul 2 13:30:13 EDT 2004


I have written v.univar. I am not sure how to calculate statistics 
for lines and areas, does the code below make sense?
Radim

Lines:
   for each line {
        sum += line_length * variable;
        sumsq += line_length * variable * variable;
        total_length += line_length;
   }
   mean = sum / total_lenght;
   population_variance = (sumsq - sum*sum/total_length)/total_length;
   population_stdev = sqrt(population_variance);

Areas: 
   for each area {
        sum += area_size * variable;
        sumsq += areas_size * variable * variable;
        total_size += area_size;
   }
   mean = sum / total_size;
   population_variance = (sumsq - sum*sum/total_size)/total_size;
   population_stdev = sqrt(population_variance);




More information about the grass-dev mailing list