diff --git a/datafit/CHANGELOG.md b/datafit/CHANGELOG.md index cfc9d5e9..6c1da742 100644 --- a/datafit/CHANGELOG.md +++ b/datafit/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.4.1 + +- Update dependency versions +- Update unit test script +- Update multivariant example + ## 1.4.0 - Update `smath` dependency diff --git a/datafit/examples/3-Multi-Variable.mjs b/datafit/examples/3-Multi-Variable.mjs index 25814b16..077f6aac 100644 --- a/datafit/examples/3-Multi-Variable.mjs +++ b/datafit/examples/3-Multi-Variable.mjs @@ -1,11 +1,8 @@ import { fit } from 'datafit'; -// Define a general 3D plane function -// x[0] represents the x-axis -// x[1] represents the y-axis -// The z-axis is represented by f([x, y], ...) -function f(x, cx, cy, cz) { - return cx * x[0] + cy * x[1] + cz; +// Define a general 3D plane function where z = f(x, y) +function f([x, y], cx, cy, cz) { + return cx * x + cy * y + cz; } // These 3 points make up the plane diff --git a/datafit/examples/package.json b/datafit/examples/package.json index 32fdb353..588fc3bb 100644 --- a/datafit/examples/package.json +++ b/datafit/examples/package.json @@ -3,6 +3,6 @@ "clean": "rm -rf node_modules package-lock.json" }, "dependencies": { - "datafit": "file:datafit-1.4.0.tgz" + "datafit": "file:datafit-1.4.1.tgz" } } \ No newline at end of file diff --git a/datafit/package.json b/datafit/package.json index 380d00fe..400d9c46 100644 --- a/datafit/package.json +++ b/datafit/package.json @@ -1,6 +1,6 @@ { "name": "datafit", - "version": "1.4.0", + "version": "1.4.1", "description": "Simple curve-fitting algorithm", "homepage": "https://npm.nicfv.com/datafit", "bin": "", @@ -51,11 +51,11 @@ "repository": "github:nicfv/npm", "license": "MIT", "dependencies": { - "smath": "1.3.5" + "smath": "1.6.1" }, "devDependencies": { - "exray": "1.0.1", + "exray": "1.0.2", "typedoc": "0.25.12", - "typescript": "5.4.3" + "typescript": "5.4.4" } } \ No newline at end of file diff --git a/datafit/src/test.ts b/datafit/src/test.ts index 56985900..7f509f90 100644 --- a/datafit/src/test.ts +++ b/datafit/src/test.ts @@ -23,17 +23,17 @@ X.eq(data[8].y, 7); // of actual, but this could // fail due to randomness. const tolerance: number = 0.20; -X.le(Math.abs((a[0] - summary.params[0]) / a[0]), tolerance); -X.le(Math.abs((a[1] - summary.params[1]) / a[1]), tolerance); -X.le(Math.abs((a[2] - summary.params[2]) / a[2]), tolerance); -X.le(Math.abs((f(-5) - summary.f(-5)) / f(-5)), tolerance); -X.le(Math.abs((f(0) - summary.f(0)) / f(0)), tolerance); -X.le(Math.abs((f(5) - summary.f(5)) / f(5)), tolerance); +X.le(Math.abs(SMath.error(summary.params[0], a[0])), tolerance); +X.le(Math.abs(SMath.error(summary.params[1], a[1])), tolerance); +X.le(Math.abs(SMath.error(summary.params[2], a[2])), tolerance); +X.le(Math.abs(SMath.error(summary.f(-5), f(-5))), tolerance); +X.le(Math.abs(SMath.error(summary.f(0), f(0))), tolerance); +X.le(Math.abs(SMath.error(summary.f(5), f(5))), tolerance); // Define 2D function g(x,y) const b = [0.5, -2, 1]; -function g(x: number[], bx: number = b[0], by: number = b[1], bz: number = b[2]): number { - return bx * x[0] + by * x[1] + bz; +function g([x, y]: Array, bx: number = b[0], by: number = b[1], bz: number = b[2]): number { + return bx * x + by * y + bz; } // Generate dataset and fit curve const data2: Datum[] = []; @@ -48,7 +48,7 @@ X.eq(data2[0].x[0], -5); X.eq(data2[0].x[1], -5); X.eq(data2[0].y, 8.5); // Validate accuracy of fitted data -X.le(Math.abs((b[0] - summary2.params[0]) / b[0]), tolerance); -X.le(Math.abs((b[1] - summary2.params[1]) / b[1]), tolerance); -X.le(Math.abs((b[2] - summary2.params[2]) / b[2]), tolerance); -X.le(Math.abs((g([-5, -5]) - summary2.f([-5, -5])) / g([-5, -5])), tolerance); \ No newline at end of file +X.le(Math.abs(SMath.error(summary2.params[0], b[0])), tolerance); +X.le(Math.abs(SMath.error(summary2.params[1], b[1])), tolerance); +X.le(Math.abs(SMath.error(summary2.params[2], b[2])), tolerance); +X.le(Math.abs(SMath.error(summary2.f([-5, -5]), g([-5, -5]))), tolerance); \ No newline at end of file diff --git a/exray/CHANGELOG.md b/exray/CHANGELOG.md index f7829c30..49e6cdec 100644 --- a/exray/CHANGELOG.md +++ b/exray/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.3 + +- Update typescript dependency version to 5.4.4 + ## 1.0.2 - Make note of using `devDependency` diff --git a/exray/examples/package.json b/exray/examples/package.json index f94e5ebb..851c86ec 100644 --- a/exray/examples/package.json +++ b/exray/examples/package.json @@ -3,6 +3,6 @@ "clean": "rm -rf node_modules package-lock.json" }, "dependencies": { - "exray": "file:exray-1.0.2.tgz" + "exray": "file:exray-1.0.3.tgz" } } \ No newline at end of file diff --git a/exray/package.json b/exray/package.json index abd6db89..73833dcf 100644 --- a/exray/package.json +++ b/exray/package.json @@ -1,6 +1,6 @@ { "name": "exray", - "version": "1.0.2", + "version": "1.0.3", "description": "Lightweight assertion testing framework", "homepage": "https://npm.nicfv.com/exray", "bin": "", @@ -42,6 +42,6 @@ "license": "MIT", "devDependencies": { "typedoc": "0.25.12", - "typescript": "5.4.3" + "typescript": "5.4.4" } } \ No newline at end of file diff --git a/smath/CHANGELOG.md b/smath/CHANGELOG.md index 27599908..29f66f48 100644 --- a/smath/CHANGELOG.md +++ b/smath/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.6.2 + +- Update dependency versions +- Add additional keywords +- Fix major bug in `median()` + ## 1.6.1 - Add `factors()` function to compute a list of prime factors of any number diff --git a/smath/examples/package.json b/smath/examples/package.json index 245b6409..50f2887b 100644 --- a/smath/examples/package.json +++ b/smath/examples/package.json @@ -3,6 +3,6 @@ "clean": "rm -rf node_modules package-lock.json" }, "dependencies": { - "smath": "file:smath-1.6.1.tgz" + "smath": "file:smath-1.6.2.tgz" } } \ No newline at end of file diff --git a/smath/package.json b/smath/package.json index 84a7cb99..922806dc 100644 --- a/smath/package.json +++ b/smath/package.json @@ -1,6 +1,6 @@ { "name": "smath", - "version": "1.6.1", + "version": "1.6.2", "description": "Small math function library", "homepage": "https://npm.nicfv.com/smath", "bin": "dist/bin.js", @@ -28,6 +28,11 @@ "avg", "average", "mean", + "calculus", + "statistics", + "numeric", + "numerical", + "analysis", "interpolate", "interpolation", "extrapolate", @@ -47,9 +52,9 @@ "repository": "github:nicfv/npm", "license": "MIT", "devDependencies": { - "@types/node": "20.11.30", + "@types/node": "20.12.4", "exray": "1.0.2", "typedoc": "0.25.12", - "typescript": "5.4.3" + "typescript": "5.4.4" } } \ No newline at end of file diff --git a/smath/src/index.ts b/smath/src/index.ts index accbd2e4..30ef808d 100644 --- a/smath/src/index.ts +++ b/smath/src/index.ts @@ -241,7 +241,7 @@ export abstract class SMath { * ``` */ public static median(data: Array): number { - data.sort(); + data.sort((a, b) => a - b); if (data.length % 2) { return data[(data.length - 1) / 2]; } diff --git a/smath/src/test.ts b/smath/src/test.ts index c8aa3cf1..de2981e4 100644 --- a/smath/src/test.ts +++ b/smath/src/test.ts @@ -91,6 +91,8 @@ X.eq(SMath.median([1]), 1); X.eq(SMath.median([1, 3]), 2); X.eq(SMath.median([1, 3, 2]), 2); X.eq(SMath.median([5, 1, 2, 3]), 2.5); +X.eq(SMath.median([10, 2, 30, 4]), 7); +X.eq(SMath.median([10, 2, 30, 4, 5]), 5); const ds1: Array = [1, 2, 3, 4], ds2: Array = [-3, 0, 1, 1, 2]; diff --git a/viridis/CHANGELOG.md b/viridis/CHANGELOG.md index f4b68a12..4ee44d30 100644 --- a/viridis/CHANGELOG.md +++ b/viridis/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.1.1 + +- Update dependency versions + ## 1.1.0 - Truncate decimal places off RGBA channels diff --git a/viridis/examples/package.json b/viridis/examples/package.json index 744038ab..d23fbf4a 100644 --- a/viridis/examples/package.json +++ b/viridis/examples/package.json @@ -3,6 +3,6 @@ "clean": "rm -rf node_modules package-lock.json" }, "dependencies": { - "viridis": "file:viridis-1.1.0.tgz" + "viridis": "file:viridis-1.1.1.tgz" } } \ No newline at end of file diff --git a/viridis/package.json b/viridis/package.json index 34c5a7f7..ab6ce9d1 100644 --- a/viridis/package.json +++ b/viridis/package.json @@ -1,6 +1,6 @@ { "name": "viridis", - "version": "1.1.0", + "version": "1.1.1", "description": "Color gradients for data visualization", "homepage": "https://npm.nicfv.com/viridis", "bin": "", @@ -43,11 +43,11 @@ "repository": "github:nicfv/npm", "license": "MIT", "dependencies": { - "smath": "1.3.4" + "smath": "1.6.1" }, "devDependencies": { - "exray": "1.0.0", + "exray": "1.0.2", "typedoc": "0.25.12", - "typescript": "5.4.3" + "typescript": "5.4.4" } } \ No newline at end of file