17

I would like to use GSL (Gnu Scientific Lib) to calculate the standard deviation of an array. http://www.gnu.org/software/gsl/manual/html_node/Mean-and-standard-deviation-and-variance.html

In the manual, the function prototype is gsl_stats_sd (const double data[], size_t stride, size_t n)

However, I don't quite understand what the "stride" is here. Would somebody know what it is?

feetwet
  • 3,248
  • 7
  • 46
  • 84
Alfred Zhong
  • 6,773
  • 11
  • 47
  • 59

1 Answers1

16

A stride is the separation in the array between two consecutive elements. If you have an array of doubles as the argument, then the stride would be 1.

The idea is that you can handle multiple data within a single array, and operate on different subcomponents of the array.

K-ballo
  • 80,396
  • 20
  • 159
  • 169
  • 1
    Thanks, K-ballo! It makes sense now! I wish to contribute to the manual to make it more clear... – Alfred Zhong May 30 '12 at 17:37
  • 2
    It should be clarified that the stride is measured in multiples of sizeof(double) from the beginning of one element to the next. Internally, GSL reads array elements like this: `data[i * stride]` – mortehu Jan 18 '15 at 00:58
  • stride is measured in multiple of sizeof(double)? WTF, why not just take the offset of the variable in the struct?? –  Jan 15 '19 at 09:55