Skip to content

Instantly share code, notes, and snippets.

@komasaru
komasaru / correlation_coefficient.rb
Last active October 3, 2020 17:33
Ruby script to calculate a correlation coefficient.
#*********************************************
# Ruby script to calculate a correlation coefficient.
#*********************************************
#
class Array
def r(y)
# 以下の場合は例外スロー
# - 引数の配列が Array クラスでない
# - 自身配列が空
# - 配列サイズが異なれば例外