Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

REnamed anomaly testing function added isValid

  • Loading branch information...
commit 44068b91297c787896dcec61c2cad40441aabca0 1 parent 8f5c708
@heikkiv authored
Showing with 21 additions and 8 deletions.
  1. +1 −1  README.md
  2. +6 −2 lib/carl.js
  3. +14 −5 test/carl.test.js
View
2  README.md
@@ -9,7 +9,7 @@ var Carl = require('./lib/carl');
var carl = new Carl(); // defaults to 0 mean, 1 variance
carl.train([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // Calculates mean and variance from data
var p = carl.pdf(3); // Value of the probability density function for given x
-var ok = carl.isSignificant(0.5); // Significance testing (returns boolean)
+var ok = carl.isAnomalous(0.5); // Anomaly testing (returns boolean)
```
## License
View
8 lib/carl.js
@@ -26,7 +26,11 @@ Carl.prototype.pdf = function(x) {
return this.distribution.pdf(x);
};
-Carl.prototype.isSignificant = function(x) {
+Carl.prototype.isAnomalous = function(x) {
var p = this.pdf(x);
- return p > epsilon;
+ return p < epsilon;
+};
+
+Carl.prototype.isValid = function(x) {
+ return !this.isAnomalous(x);
};
View
19 test/carl.test.js
@@ -28,11 +28,20 @@ describe('Carl', function() {
it('should determine significance with epsilon .05', function() {
var carl = new Carl();
- carl.isSignificant(0).should.be.true;
- carl.isSignificant(0.5).should.be.true;
- carl.isSignificant(-0.5).should.be.true;
- carl.isSignificant(3).should.be.false;
- carl.isSignificant(-3).should.be.false;
+ carl.isAnomalous(0).should.be.false;
+ carl.isAnomalous(0.5).should.be.false;
+ carl.isAnomalous(-0.5).should.be.false;
+ carl.isAnomalous(3).should.be.true;
+ carl.isAnomalous(-3).should.be.true;
+ });
+
+ it('should return opposite of isAnomalous with iValid', function() {
+ var carl = new Carl();
+ carl.isValid(0).should.be.true;
+ carl.isValid(0.5).should.be.true;
+ carl.isValid(-0.5).should.be.true;
+ carl.isValid(3).should.be.false;
+ carl.isValid(-3).should.be.false;
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.