@danielsimonjr/mathts-parallel 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +9 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,5 +1,11 @@
1
1
  // src/ComputePool.ts
2
- import { pairwiseSum, norm2, pairwiseDot, scaledDistance } from "@danielsimonjr/mathts-core";
2
+ import {
3
+ pairwiseSum,
4
+ norm2,
5
+ pairwiseDot,
6
+ scaledDistance,
7
+ sumSquaredDeviations
8
+ } from "@danielsimonjr/mathts-core";
3
9
  import {
4
10
  MathWorkerPool,
5
11
  Transfer
@@ -742,12 +748,8 @@ var ComputePool = class {
742
748
  async variance(data) {
743
749
  if (!this.shouldParallelize(data.length, "variance")) {
744
750
  const n = data.length;
745
- let mean = 0;
746
- for (let i = 0; i < n; i++) mean += data[i];
747
- mean = n > 0 ? mean / n : 0;
748
- let acc = 0;
749
- for (let i = 0; i < n; i++) acc += (data[i] - mean) ** 2;
750
- const variance = n > 0 ? acc / n : 0;
751
+ const mean = n > 0 ? pairwiseSum(data) / n : 0;
752
+ const variance = n > 0 ? sumSquaredDeviations(data) / n : 0;
751
753
  return this.seqResult({ mean, variance, std: Math.sqrt(variance) });
752
754
  }
753
755
  return toParallelResult(await this.workerPool.variance(data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-parallel",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "WebWorker parallelization for MathTS computations",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@danielsimonjr/mathts-workerpool": "^0.2.1",
35
- "@danielsimonjr/mathts-core": "^0.9.0"
35
+ "@danielsimonjr/mathts-core": "^0.10.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^25.5.2",