Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Aug 25, 2023
1 parent a2d894e commit 107355b
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions integration_tests/test_statistics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from statistics import (mean, fmean, geometric_mean, harmonic_mean, variance,
stdev, pvariance, pstdev, correlation, covariance,
linear_regression, mode)
stdev, pvariance, pstdev,
mode)
from lpython import i32, f64, i64, f32


Expand Down Expand Up @@ -127,67 +127,67 @@ def test_pstdev():
assert abs(k - 0.37537181567080935) < eps


def test_covariance():
a: list[i32]
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
b: list[i32]
b = [1, 2, 3, 1, 2, 3, 1, 2, 3]
j: f64
j = covariance(a, b)
assert abs(j - 0.75) < eps
# def test_covariance():
# a: list[i32]
# a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# b: list[i32]
# b = [1, 2, 3, 1, 2, 3, 1, 2, 3]
# j: f64
# j = covariance(a, b)
# assert abs(j - 0.75) < eps

c: list[f64]
c = [2.74, 1.23, 2.63, 2.22, 3.0, 1.98]
d: list[f64]
d = [9.4, 1.23, 2.63, 22.4, 1.9, 13.98]
k: f64
k = covariance(c, d)
assert abs(k + 0.24955999999999934) < eps
# c: list[f64]
# c = [2.74, 1.23, 2.63, 2.22, 3.0, 1.98]
# d: list[f64]
# d = [9.4, 1.23, 2.63, 22.4, 1.9, 13.98]
# k: f64
# k = covariance(c, d)
# assert abs(k + 0.24955999999999934) < eps


def test_correlation():
a: list[i32]
a = [11, 2, 7, 4, 15, 6, 10, 8, 9, 1, 11, 5, 13, 6, 15]
b: list[i32]
b = [2, 5, 17, 6, 10, 8, 13, 4, 6, 9, 11, 2, 5, 4, 7]
# def test_correlation():
# a: list[i32]
# a = [11, 2, 7, 4, 15, 6, 10, 8, 9, 1, 11, 5, 13, 6, 15]
# b: list[i32]
# b = [2, 5, 17, 6, 10, 8, 13, 4, 6, 9, 11, 2, 5, 4, 7]

j: f64
j = correlation(a, b)
assert abs(j - 0.11521487988958108) < eps
# j: f64
# j = correlation(a, b)
# assert abs(j - 0.11521487988958108) < eps

c: list[f64]
c = [2.0, 23.0, 24.55, 64.436, 5403.23]
d: list[f64]
d = [26.9, 75.6, 34.06, 356.89, 759.26]
# c: list[f64]
# c = [2.0, 23.0, 24.55, 64.436, 5403.23]
# d: list[f64]
# d = [26.9, 75.6, 34.06, 356.89, 759.26]

j = correlation(c, c)
assert abs(j - 1.0) < eps
# j = correlation(c, c)
# assert abs(j - 1.0) < eps

j = correlation(c, d)
assert abs(j - 0.9057925526720572) < eps
# j = correlation(c, d)
# assert abs(j - 0.9057925526720572) < eps

def test_linear_regression():
c: list[f64]
c = [2.74, 1.23, 2.63, 2.22, 3.0, 1.98]
d: list[f64]
d = [9.4, 1.23, 2.63, 22.4, 1.9, 13.98]
# def test_linear_regression():
# c: list[f64]
# c = [2.74, 1.23, 2.63, 2.22, 3.0, 1.98]
# d: list[f64]
# d = [9.4, 1.23, 2.63, 22.4, 1.9, 13.98]

slope: f64
intercept: f64
slope, intercept = linear_regression(c, d)
# slope: f64
# intercept: f64
# slope, intercept = linear_regression(c, d)

assert abs(slope + 0.6098133124816717) < eps
assert abs(intercept - 9.992570618707845) < eps
# assert abs(slope + 0.6098133124816717) < eps
# assert abs(intercept - 9.992570618707845) < eps

a: list[i32]
b: list[i32]
a = [12, 24, 2, 1, 43, 53, 23]
b = [2, 13, 14, 63, 49, 7, 3]
# a: list[i32]
# b: list[i32]
# a = [12, 24, 2, 1, 43, 53, 23]
# b = [2, 13, 14, 63, 49, 7, 3]

slope, intercept = linear_regression(a, b)
# slope, intercept = linear_regression(a, b)

assert abs(slope + 0.18514007308160782) < eps
assert abs(intercept - 25.750304506699152) < eps
# assert abs(slope + 0.18514007308160782) < eps
# assert abs(intercept - 25.750304506699152) < eps

def test_mode():
a: list[i32]
Expand Down Expand Up @@ -228,9 +228,9 @@ def check():
test_stdev()
test_pvariance()
test_pstdev()
test_linear_regression()
test_correlation()
test_covariance()
# test_linear_regression()
# test_correlation()
# test_covariance()
test_mode()

check()

0 comments on commit 107355b

Please sign in to comment.