3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rubyで相関係数の算出

Posted at

SciRubyファミリーのStatsampleを使って、相関係数を一発で算出する。

require 'statsample'
a = [1,2,3,4,5,6].to_vector
b = [5,2,nil,4,3,8].to_vector
pearson = Statsample::Bivariate::Pearson.new(a,b)
puts pearson.r
puts pearson.t
puts pearson.probability
puts pearson.summary
0.4608403716896188
0.8993962691856522
0.4347262709638615
Correlation ( - ) : r=0.461 (t:0.899, g.l.=3, p:0.435 / both tails)
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?