Exemplo n.º 1
0
def covariance(xVec, yVec):
    #tester = np.vstack((xVec,yVec))
    n=len(xVec)
    xBar = mean(xVec)
    yBar = mean(yVec)
    covar = 0;
    for i in range(0,n):
        covar += float((xVec[i]-xBar)*(yVec[i]-yBar))
    #print("The python covariance is " + str(np.cov(tester)))
    #print("The N covariance is: " + str(covar/n))
    return covar/(n-1) #The sample covariance
Exemplo n.º 2
0
def test_complex():
    # given that complex numbers are an unordered field
    # the arithmetic mean of complex numbers is meaningless
    num_list = [2 + 3j, 3 + 4j, -32 - 2j]
    obs = mean(num_list)
    exp = NotImplemented
    assert obs == exp
Exemplo n.º 3
0
def test_complex():
    # given that complex numbers are an unordered field
    # the arithmetic mean of complex numbers is meaningless
    num_list = [2 + 3j, 3 + 4j, -32 - 2j]
    obs = mean(num_list)
    exp = NotImplemented
    assert obs == exp
Exemplo n.º 4
0
def test_ints():

    # test caculating the mean of ints

    num_list = [1, 2, 3, 4, 5]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
Exemplo n.º 5
0
def test_neg():
    nums = [
        -1,
        1,
    ]
    obs = mean(nums)
    exp = 0
    assert obs == exp
Exemplo n.º 6
0
def test_zero():
    num_list=[0,2,4,6]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
Exemplo n.º 7
0
def test_neg():
    num_list = [-1, 1]
    obs = mean(num_list)
    exp = 0
    assert obs == exp
Exemplo n.º 8
0
def test_zero():
    num_list=[0,2,4,6]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
Exemplo n.º 9
0
def test_long():
    big = 100000000
    obs = mean(range(1,big))
    exp = big/2.0
    assert obs == exp
Exemplo n.º 10
0
def test_ints():
    num_list = [1,2,3,4,5]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
Exemplo n.º 11
0
def test_neg():
    num_list = [3, 4, 8, -3]
    obs = 3
    exp = mean(num_list)
    assert obs == exp
Exemplo n.º 12
0
def test_mean_1234():
    values=[1.,2.,3.,4.]
    calc_mean= mean(values)
    expected_mean=2.5
    assert expected_mean==calc_mean
Exemplo n.º 13
0
def test_neg():
    num = [4, -3, 5]
    obs = mean(num)
    exp = 2
    assert obs == exp
Exemplo n.º 14
0
def test_zero():
    num = [4, 0, 6]
    obs = mean(num)
    exp = 3
    assert obs == exp
Exemplo n.º 15
0
def test_double():
  num_list=[1,2,3,4]
  obs = mean(num_list)
  exp = 2.5
  assert obs == exp
Exemplo n.º 16
0
def test_zero():
    num_list = [0., 2., 4., 6.]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
Exemplo n.º 17
0
import statistics import mean
import sys

i = 0
a_numbers = []

for argv in sys.argv:
    a_numbers.append(sys.argv[i])
    i = i+0

del a_numbers[0]

print("mean:" (mean(a_numbers))


Exemplo n.º 18
0
def test_long():
    big = 100000000
    obs = mean(range(1,big))
    exp = big/2.0
    assert obs == exp
Exemplo n.º 19
0
def test_long():
    big = 1000000
    obs = mean(range(1, big))
    exp = big / 2.0
    assert_almost_equal(obs, exp)
Exemplo n.º 20
0
def test_ints():
    num = [4, 3, 6]
    obs = mean(num)
    exp = 4
    assert obs == exp
Exemplo n.º 21
0
def sSE(yhat,y):
    ybar = mean(y)
    sse = 0
    for i in range(0,len(yhat)):
        sse += (yhat[i]-ybar)**2
    return sse
Exemplo n.º 22
0
def test_negative():
    nums = [-3, 0, 0]
    obs = mean(nums)
    exp = -1
    assert obs == exp
Exemplo n.º 23
0
def test_ints():
    num_list = [2, 3, 4]
    obs = 3
    exp = mean(num_list)
    assert obs == exp
Exemplo n.º 24
0
def test_empty():
    nums = []
    obs = mean(nums)
    assert math.isnan(obs)
Exemplo n.º 25
0
def test_double():
    # This one will fail in Python 2
    num_list=[1,2,3,4]
    obs = mean(num_list)
    exp = 2.5
    assert obs == exp
Exemplo n.º 26
0
def test_mean_1234():
    values = [1., 2., 3., 4.]
    calc_mean = mean(values)
    expected_mean = 2.5
    assert expected_mean == calc_mean
Exemplo n.º 27
0
def test_mean_1234():
    num_list = [1,2,3,4]
    calc_mean = mean(num_list)
    expected_mean = 2.5
    assert expected_mean == calc_mean
Exemplo n.º 28
0
def test_ints():
    num_list = [4, 5, 28, 3]
    obs = mean(num_list)
    exp = 10
    assert obs == exp
Exemplo n.º 29
0
def test_zero():
    num_list = [0, 3, 3]
    obs = mean(num_list)
    exp = 2
    assert obs == exp
Exemplo n.º 30
0
def testZero():
    nums = [0, 0, 0]
    obs = mean(nums)
    exp = 0
    assert obs == exp
Exemplo n.º 31
0
def test_ints():
    num_list = [3, 4, 5]
    obs = mean(num_list)
    exp = 4
    assert obs == exp
Exemplo n.º 32
0
def test_ints():
    num_list = [1,2,3,4,5]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
Exemplo n.º 33
0
def test_double():
    # This one will fail in Python 2
    num_list=[1,2,3,4]
    obs = mean(num_list)
    exp = 2.5
    assert obs == exp
Exemplo n.º 34
0
def test1():
    list = [0, 4, 5]
    obs = mean(list)
    exp = 3
    assert obs == exp
Exemplo n.º 35
0
def testNeg():
    nums = [-1, -1, -1]
    obs = mean(nums)
    exp = -1
    assert obs == exp
Exemplo n.º 36
0
def test_zero():
    num_list=[0.,2.,4.,6.]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
Exemplo n.º 37
0
def test_mean_1234():
    num_list = [1, 2, 3, 4, 5]
    calc_mean = mean(num_list)
    expected_mean = 3
    assert expected_mean == calc_mean
Exemplo n.º 38
0
def testInts():
    nums = [4, 5, 28, 3]
    obs = mean(nums)
    exp = 10
    assert obs == exp
Exemplo n.º 39
0
def test():
    list = [3, 4, 5]
    obs = mean(list)
    exp = 4
    assert obs == exp
Exemplo n.º 40
0
def test_double():
    num_list = [1, 2, 3, 4]
    obs = mean(num_list)
    exp = 2.5
    assert obs == exp
Exemplo n.º 41
0
def test_zero():
    num_list = [3, 0, 5, 4]
    obs = 3
    exp = mean(num_list)
    assert obs == exp
Exemplo n.º 42
0
def test_mean_12345():
    num_list=[1,2,3,4,5]
    calc_mean=mean(num_list)
    expected_mean=3
    assert expected_mean == calc_mean