title: GSL and correlation
body: <p>I'm using the GSL library 1.14 and the ruby wrapper (<a href="http://rubygems.org/gems/gsl" rel="nofollow">gsl</a>) for some math calculation. One thing that I need is the Pearson correlation. But I have a problem when 0 in my array.</p>
  
  <p>For example I have this snippet of code:</p>
  
  <pre><code>x = [1,2,2,2,12]
  y = [1,2,1,3,33]
  
  puts GSL::Stats::correlation(
    GSL::Vector.alloc(x),GSL::Vector.alloc(y)
  )
  =&gt; 0.9967291641974002
  </code></pre>
  
  <p>But when I try to calculate it with the following array values, I get an NaN:</p>
  
  <pre><code>x = [1,1,1]
  y = [1,1,1]
  or
  x = [0,1,1]
  y = [1,1,1]
  
  puts GSL::Stats::correlation(
    GSL::Vector.alloc(x),GSL::Vector.alloc(y)
  )
  =&gt; NaN
  </code></pre>
  
  <p>And when I try with this values, it works:</p>
  
  <pre><code>x = [0,1,1]
  y = [1,0,1]
  
  puts GSL::Stats::correlation(
    GSL::Vector.alloc(x),GSL::Vector.alloc(y)
  )
  =&gt; -0.5
  </code></pre>
  
  <p>Does anybody know why? this is very strange, isn't it?</p>