Exemplo n.º 1
0
    def confidenceInterval(data, confidence):
        PopulationSampling._checkList(data)

        mean = DescriptiveStatistics.mean(data)
        se = scipy.stats.sem(data)
        i = se * PopulationSampling.tscore(len(data), confidence)
        return [mean, mean - i, mean + i]
	def test_stdev(self):
		self.assertAlmostEqual(277.78211542, DescriptiveStatistics.stdev(self.testdata))
	def test_mode_multiple(self):
		data = [1, 7, 4, 7, 2, 8, 4]
		self.assertEqual([4, 7], DescriptiveStatistics.mode(data))
	def test_mode_single(self):
		data = [1, 7, 4, 7, 2, 8]
		self.assertEqual([7], DescriptiveStatistics.mode(data))
	def mode(self, data):
		self.result = DescriptiveStatistics.mode(data)
		return self.result
	def test_meanDeviation(self):
		self.assertAlmostEqual(214.16539738, DescriptiveStatistics.meanDeviation(self.testdata))
	def test_skewness(self):
		self.assertAlmostEqual(0.17767941, DescriptiveStatistics.skewness(self.testdata))
	def test_pcovariance(self):
		data1 = [14.2, 16.4, 11.9, 15.2, 18.5]
		data2 = [215, 325, 185, 332, 406]

		self.assertEqual(169.156, DescriptiveStatistics.pcovariance(data1, data2))
	def sampleCorrelation(self, data1, data2):
		self.result = DescriptiveStatistics.sampleCorrelation(data1, data2)
		return self.result
	def meanDeviation(self, data):
		self.result = DescriptiveStatistics.meanDeviation(data)
		return self.result
	def zscore(self, value, mean, stdev):
		self.result = DescriptiveStatistics.zscore(value, mean, stdev)
		return self.result
	def skewness(self, data):
		self.result = DescriptiveStatistics.skewness(data)
		return self.result
	def quartiles(self, data):
		self.result = DescriptiveStatistics.quartiles(self.testdata)
		return self.result
	def variance(self, data):
		self.result = DescriptiveStatistics.variance(data)
		return self.result
	def stdev(self, data):
		self.result = DescriptiveStatistics.stdev(data)
		return self.result
	def test_pstdev(self):
		self.assertAlmostEqual(270.74851517, DescriptiveStatistics.pstdev(self.testdata))
	def test_variance(self):
		self.assertAlmostEqual(77162.90365125, DescriptiveStatistics.variance(self.testdata))
	def populationCorrelation(self, data1, data2):
		self.result = DescriptiveStatistics.populationCorrelation(data, data2)
		return self.result
	def test_quartiles(self):
		self.assertEqual([168.01569232654998, 390.26554121388835, 557.6497868225864], DescriptiveStatistics.quartiles(self.testdata))
	def test_mean(self):
		self.assertAlmostEqual(406.71759600, DescriptiveStatistics.mean(self.testdata))
	def test_zscore(self):
		value = 1100
		mean = 1026
		stdev = 209
		self.assertAlmostEqual(0.35406698, DescriptiveStatistics.zscore(value, mean, stdev))
	def test_median(self):
		self.assertAlmostEqual(390.26554121, DescriptiveStatistics.median(self.testdata))
	def test_population_correlation(self):
		data1 = [14.2, 16.4, 11.9, 15.2, 18.5]
		data2 = [215, 325, 185, 332, 406]

		self.assertAlmostEqual(0.94532854, DescriptiveStatistics.populationCorrelation(data1, data2))
	def median(self, data):
		self.result = DescriptiveStatistics.median(data)
		return self.result