node-red-contrib-prib-functions
Advanced tools
Comparing version 0.16.0 to 0.16.1
const logger = new (require("node-red-contrib-logger"))("Data Analysis"); | ||
logger.sendInfo("Copyright 2020 Jaroslav Peter Prib"); | ||
Object.defineProperty(Array.prototype, "last", { | ||
value() { | ||
return this[this.length-1]; | ||
}, | ||
writable: true, | ||
configurable: true | ||
}); | ||
require("./arrayLast"); | ||
const ed=require("./euclideanDistance.js"); | ||
require("./forNestedEach"); | ||
@@ -123,4 +119,14 @@ function crossNormalisedDeltas() { | ||
} | ||
function getColumns(node) { | ||
if(node.columns) { | ||
if(node.columns instanceof Array) return node.columns | ||
return eval("["+node.columns+"]"); | ||
} | ||
} | ||
functions={ | ||
avg:(d)=>functions.sum(d)/d.length, | ||
arrayMax:(d)=>{ // not tested | ||
let max=[],indices | ||
a.forNestedEach((e,f,l)=>{const i=l[l.length-1];if(max[l]<e) {max=e,indices=l}}) | ||
}, | ||
covariance: (d)=>{ | ||
@@ -145,7 +151,12 @@ const means=[],covars=[],dl=d.length,dlminus1=dl-1,N=d[0].length; | ||
const stdDev=d.map(c=>functions.stdDev(c)); | ||
logger.send({label:"test",d:d,covars:covars,stdDev:stdDev}); | ||
return 1//covars.map((a)=>a.map((c,i)=>c==null?null:c/(stdDev[i+1]*stdDev[i]))); | ||
return covars.map((a)=>a.map((c,i)=>c==null?null:c/(stdDev[i+1]*stdDev[i]))); | ||
}, | ||
deltas :(d)=>d.map( (c,i)=>c-(d[i-1]||0) ), | ||
deltaNormalised :(d)=>d.map( (c,i)=>(c-(d[i-1]||0)) / (d[i-1]||0) ), | ||
distances: (d,term,node)=>{ | ||
if(node.columns) return ed.distances(d,getColumns(node)) | ||
return ed.distances(d); | ||
}, | ||
distancesMin: (d,term,node)=>ed.minDistances(d,getColumns(node)), | ||
distancesMax: (d,term,node)=>ed.maxDistances(d,getColumns(node)), | ||
max: (d)=> Math.max(...d), | ||
@@ -389,2 +400,3 @@ median:(d)=>{ | ||
} catch(ex) { | ||
if(logger.active) logger.send({label:"error input",action:node.action,message:ex.message,stack:ex.stack}); | ||
msg.error=ex.message; | ||
@@ -391,0 +403,0 @@ if(node.maxErrorDisplay) { |
{ | ||
"name": "node-red-contrib-prib-functions", | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"description": "Node-RED added node functions.", | ||
@@ -9,3 +9,3 @@ "dependencies": { | ||
"node-red-contrib-logger": "^0.0.6", | ||
"xlsx": "^0.16.9" | ||
"xlsx": "^0.17.0" | ||
}, | ||
@@ -22,3 +22,3 @@ "devDependencies": { | ||
"scripts": { | ||
"test": "mocha \"test/**/*.js\"" | ||
"test": "mocha \"test/**/e*.js\"" | ||
}, | ||
@@ -44,2 +44,4 @@ "repository": { | ||
"delta", | ||
"distance", | ||
"euclidian distance", | ||
"EMA", | ||
@@ -46,0 +48,0 @@ "EWMA", |
@@ -53,2 +53,7 @@ # [node-red-contrib-prib-functions][2] | ||
Array data | ||
* distances | ||
* minimum distance(s) between points | ||
* maximum distance(s) between points | ||
![Data Analysis](documentation/DataAnalysis.JPG "Data Analysis") | ||
@@ -246,2 +251,4 @@ | ||
0.16.10 data analysis add eulcidean distance functions. Add array pairs | ||
0.16.0 fix data analysis variance and stddev, add sample, add tests | ||
@@ -248,0 +255,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1303421
71
5129
320
8
+ Addedcodepage@1.15.0(transitive)
+ Addedxlsx@0.17.5(transitive)
- Removedcodepage@1.14.0(transitive)
- Removedcommander@2.14.12.17.1(transitive)
- Removedfflate@0.3.11(transitive)
- Removedxlsx@0.16.9(transitive)
Updatedxlsx@^0.17.0