lundi 25 janvier 2016

Downscale array for decimal factor

Is there efficient way to downscale number of elements in array by decimal factor?

I want to downsize elements from one array by certain factor.

Example: If I have 10 elements and need to scale down by factor 2.

1 2 3 4 5 6 7 8 9 10
scaled to
1.5 3.5 5.5 7.5 9.5

Grouping 2 by 2 and use arithmetic mean.

My problem is what if I need to downsize array with 10 elements to 6 elements? In theory I should group 1.6 elements and find their arithmetic mean, but how to do that?

Aucun commentaire:

Enregistrer un commentaire