Here is a sample of my input file :
$cat NDVI-bm P01 031.RAW 0.516 0 0 P01 021.RAW 0.449 0 0 P02 045.RAW 0.418 0 0 P03 062.RAW 0.570 0 0 P03 064.RAW 0.
{ total[$1] += $3; ++n[$1] } END { for(i in total) print i, total[i] / n[i] }