| 
									
										
										
										
											2016-08-03 15:00:07 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-02-11 10:13:49 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-27 17:12:25 -07:00
										 |  |  | import {describe, expect, it} from '@angular/core/testing/testing_internal'; | 
					
						
							| 
									
										
										
										
											2016-08-26 16:34:08 -07:00
										 |  |  | import {Statistic} from '../src/statistic'; | 
					
						
							| 
									
										
										
										
											2015-02-11 10:13:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('statistic', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should calculate the mean', () => { | 
					
						
							|  |  |  |       expect(Statistic.calculateMean([])).toBeNaN(); | 
					
						
							| 
									
										
										
										
											2015-05-27 14:57:54 -07:00
										 |  |  |       expect(Statistic.calculateMean([1, 2, 3])).toBe(2.0); | 
					
						
							| 
									
										
										
										
											2015-02-11 10:13:49 -08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should calculate the standard deviation', () => { | 
					
						
							|  |  |  |       expect(Statistic.calculateStandardDeviation([], NaN)).toBeNaN(); | 
					
						
							|  |  |  |       expect(Statistic.calculateStandardDeviation([1], 1)).toBe(0.0); | 
					
						
							|  |  |  |       expect(Statistic.calculateStandardDeviation([2, 4, 4, 4, 5, 5, 7, 9], 5)).toBe(2.0); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should calculate the coefficient of variation', () => { | 
					
						
							|  |  |  |       expect(Statistic.calculateCoefficientOfVariation([], NaN)).toBeNaN(); | 
					
						
							|  |  |  |       expect(Statistic.calculateCoefficientOfVariation([1], 1)).toBe(0.0); | 
					
						
							|  |  |  |       expect(Statistic.calculateCoefficientOfVariation([2, 4, 4, 4, 5, 5, 7, 9], 5)).toBe(40.0); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should calculate the regression slope', () => { | 
					
						
							|  |  |  |       expect(Statistic.calculateRegressionSlope([], NaN, [], NaN)).toBeNaN(); | 
					
						
							|  |  |  |       expect(Statistic.calculateRegressionSlope([1], 1, [2], 2)).toBeNaN(); | 
					
						
							| 
									
										
										
										
											2015-05-27 14:57:54 -07:00
										 |  |  |       expect(Statistic.calculateRegressionSlope([1, 2], 1.5, [2, 4], 3)).toBe(2.0); | 
					
						
							| 
									
										
										
										
											2015-02-11 10:13:49 -08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | } |