예제 #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
예제 #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
예제 #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
예제 #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
예제 #5
0
def test_neg():
    nums = [
        -1,
        1,
    ]
    obs = mean(nums)
    exp = 0
    assert obs == exp
예제 #6
0
def test_zero():
    num_list=[0,2,4,6]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #7
0
def test_neg():
    num_list = [-1, 1]
    obs = mean(num_list)
    exp = 0
    assert obs == exp
예제 #8
0
def test_zero():
    num_list=[0,2,4,6]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #9
0
def test_long():
    big = 100000000
    obs = mean(range(1,big))
    exp = big/2.0
    assert obs == exp
예제 #10
0
def test_ints():
    num_list = [1,2,3,4,5]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #11
0
def test_neg():
    num_list = [3, 4, 8, -3]
    obs = 3
    exp = mean(num_list)
    assert obs == exp
예제 #12
0
def test_mean_1234():
    values=[1.,2.,3.,4.]
    calc_mean= mean(values)
    expected_mean=2.5
    assert expected_mean==calc_mean
예제 #13
0
def test_neg():
    num = [4, -3, 5]
    obs = mean(num)
    exp = 2
    assert obs == exp
예제 #14
0
def test_zero():
    num = [4, 0, 6]
    obs = mean(num)
    exp = 3
    assert obs == exp
예제 #15
0
파일: test_mean.py 프로젝트: CeasarSS/books
def test_double():
  num_list=[1,2,3,4]
  obs = mean(num_list)
  exp = 2.5
  assert obs == exp
예제 #16
0
def test_zero():
    num_list = [0., 2., 4., 6.]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #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))


예제 #18
0
def test_long():
    big = 100000000
    obs = mean(range(1,big))
    exp = big/2.0
    assert obs == exp
예제 #19
0
def test_long():
    big = 1000000
    obs = mean(range(1, big))
    exp = big / 2.0
    assert_almost_equal(obs, exp)
예제 #20
0
def test_ints():
    num = [4, 3, 6]
    obs = mean(num)
    exp = 4
    assert obs == exp
예제 #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
예제 #22
0
def test_negative():
    nums = [-3, 0, 0]
    obs = mean(nums)
    exp = -1
    assert obs == exp
예제 #23
0
def test_ints():
    num_list = [2, 3, 4]
    obs = 3
    exp = mean(num_list)
    assert obs == exp
예제 #24
0
def test_empty():
    nums = []
    obs = mean(nums)
    assert math.isnan(obs)
예제 #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
예제 #26
0
def test_mean_1234():
    values = [1., 2., 3., 4.]
    calc_mean = mean(values)
    expected_mean = 2.5
    assert expected_mean == calc_mean
예제 #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
예제 #28
0
def test_ints():
    num_list = [4, 5, 28, 3]
    obs = mean(num_list)
    exp = 10
    assert obs == exp
예제 #29
0
def test_zero():
    num_list = [0, 3, 3]
    obs = mean(num_list)
    exp = 2
    assert obs == exp
예제 #30
0
def testZero():
    nums = [0, 0, 0]
    obs = mean(nums)
    exp = 0
    assert obs == exp
예제 #31
0
def test_ints():
    num_list = [3, 4, 5]
    obs = mean(num_list)
    exp = 4
    assert obs == exp
예제 #32
0
def test_ints():
    num_list = [1,2,3,4,5]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #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
예제 #34
0
파일: mean_test.py 프로젝트: BopingC/python
def test1():
    list = [0, 4, 5]
    obs = mean(list)
    exp = 3
    assert obs == exp
예제 #35
0
def testNeg():
    nums = [-1, -1, -1]
    obs = mean(nums)
    exp = -1
    assert obs == exp
예제 #36
0
def test_zero():
    num_list=[0.,2.,4.,6.]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #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
예제 #38
0
def testInts():
    nums = [4, 5, 28, 3]
    obs = mean(nums)
    exp = 10
    assert obs == exp
예제 #39
0
파일: mean_test.py 프로젝트: BopingC/python
def test():
    list = [3, 4, 5]
    obs = mean(list)
    exp = 4
    assert obs == exp
예제 #40
0
def test_double():
    num_list = [1, 2, 3, 4]
    obs = mean(num_list)
    exp = 2.5
    assert obs == exp
예제 #41
0
def test_zero():
    num_list = [3, 0, 5, 4]
    obs = 3
    exp = mean(num_list)
    assert obs == exp
예제 #42
0
파일: mod_tests.py 프로젝트: JMGnx/tests
def test_mean_12345():
    num_list=[1,2,3,4,5]
    calc_mean=mean(num_list)
    expected_mean=3
    assert expected_mean == calc_mean