ID EN
Statistics

correlation

Python 3.11 🇮🇩 Bahasa Indonesia

Kembalikan koefisien korelasi Pearson untuk dua masukan. Koefisien korelasi Pearson r mengambil nilai antara -1 dan +1. Ini mengukur kekuatan dan arah hubungan linier.

Syntax

PYTHON
statistics.correlation(x, y, /)

Contoh

Example 1
PYTHON
>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> y = [9, 8, 7, 6, 5, 4, 3, 2, 1]
>>> correlation(x, x)
1.0
>>> correlation(x, y)
-1.0

See Also

StatisticsError