[GRASS5] v.univar

Roger Bivand Roger.Bivand at nhh.no
Fri Jul 2 13:52:02 EDT 2004


On Fri, 2 Jul 2004, Radim Blazek wrote:

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

Briefly, no. You are calculating weighted means, weighting by line length
or area surface size. I think it would be better to treat each line or
area as a discrete, unweighted, unit unless some reason to the contrary is
given, just like points/sites. It is probably more important to handle
missing data gracefully than weight the means or other statistics, I
think. There may be reasons to weight sometimes, but most often I see
ratios or rates of two variables, rather than of a single variable and
length or area.

Roger

> 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);
> 
> _______________________________________________
> grass5 mailing list
> grass5 at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass5
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no





More information about the grass-dev mailing list