Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np


def Sxy(lx,ly=0):
	if ly == 0:
		ly=lx
	if len(lx) != len(ly):
		print("List length different \n\n")
	sxy = 0
	sx = 0
	sy = 0
	for i in range(len(lx)):
		sxy += lx[i]*ly[i]
		sx  += lx[i]
		sy  += ly[i]
	
	return sxy - sx*sy*len(lx)**-1

def r(lx,ly=0):
	if ly == 0:
		ly=lx
	
	return Sxy(lx,ly)*(Sxy(lx)*Sxy(ly))**-0.5

print(r(list(range(10)),[2080,1160,910,820,800,810,850,890,940,1000]))