@zukhruf/statistics 0.8.43 → 0.8.44
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.
- package/README.md +81 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,88 @@ These parts stay with each caller, because each caller has its own rule:
|
|
|
63
63
|
- an interval with a rule of its own at each end, such as the `lower` method at the low end and the `higher` method at the high end of the Structured Output Benchmark: its caller writes it as a `ConfidenceIntervalMethod`;
|
|
64
64
|
- a p-value and a verdict, such as "better" when the interval of a difference lies above 0: each caller builds its rule from `isAbove` and `isBelow`.
|
|
65
65
|
|
|
66
|
+
## Errors
|
|
67
|
+
|
|
68
|
+
Each error is a `RangeError`. Its message says which input is out of range.
|
|
69
|
+
|
|
70
|
+
| Error | When |
|
|
71
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
72
|
+
| `RangeError` | `QuantileMethod.of` gets a `q` that is not from 0 to 1, or NaN: `A quantile is from 0 to 1, not 1.5` (`src/quantile/quantile-method.ts`). |
|
|
73
|
+
| `RangeError` | `QuantileMethod.of` gets no values: `A quantile needs at least one value`. `PercentileInterval.of` of an empty distribution throws it too. |
|
|
74
|
+
| `RangeError` | `IidBootstrap.distribution` or `IidBootstrap.interval` gets data with no items: `A bootstrap needs at least one item` (`src/bootstrap/iid-bootstrap.ts`). |
|
|
75
|
+
| `RangeError` | `randomIndex(n)` gives an index out of 0 to n − 1: `A random index is from 0 to 9, not 10`. |
|
|
76
|
+
|
|
77
|
+
## API
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// numpy.sum, numpy.mean and numpy.nanmean of a 1-D float64 array.
|
|
81
|
+
function sum(values: ArrayLike<number>): number;
|
|
82
|
+
function mean(values: ArrayLike<number>): number;
|
|
83
|
+
function nanmean(values: ArrayLike<number>): number;
|
|
84
|
+
|
|
85
|
+
// A method of numpy.quantile. A subclass gives only where its rule reads the values.
|
|
86
|
+
abstract class QuantileMethod {
|
|
87
|
+
of(sorted: readonly number[], q: number): number;
|
|
88
|
+
protected abstract valueAt(sorted: readonly number[], q: number): number;
|
|
89
|
+
protected static value(sorted: readonly number[], index: number): number;
|
|
90
|
+
}
|
|
91
|
+
class Lower extends QuantileMethod {}
|
|
92
|
+
class Higher extends QuantileMethod {}
|
|
93
|
+
class Linear extends QuantileMethod {}
|
|
94
|
+
class InvertedCdf extends QuantileMethod {}
|
|
95
|
+
|
|
96
|
+
class ConfidenceInterval {
|
|
97
|
+
constructor(low: number, high: number);
|
|
98
|
+
readonly low: number;
|
|
99
|
+
readonly high: number;
|
|
100
|
+
isAbove(value: number): boolean;
|
|
101
|
+
isBelow(value: number): boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
class DifferenceInterval extends ConfidenceInterval {
|
|
105
|
+
constructor(low: number, high: number, observed: number);
|
|
106
|
+
readonly observed: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The method of scipy.stats.bootstrap. Exported as a type only.
|
|
110
|
+
interface ConfidenceIntervalMethod {
|
|
111
|
+
of(distribution: readonly number[]): ConfidenceInterval;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class PercentileInterval implements ConfidenceIntervalMethod {
|
|
115
|
+
constructor(options: {
|
|
116
|
+
readonly low: number;
|
|
117
|
+
readonly high: number;
|
|
118
|
+
readonly method: QuantileMethod;
|
|
119
|
+
});
|
|
120
|
+
of(distribution: readonly number[]): ConfidenceInterval;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
class IidBootstrap {
|
|
124
|
+
constructor(options: {
|
|
125
|
+
readonly nResamples: number;
|
|
126
|
+
readonly randomIndex: (n: number) => number;
|
|
127
|
+
});
|
|
128
|
+
distribution<T>(
|
|
129
|
+
data: readonly T[],
|
|
130
|
+
statistic: (resample: readonly T[]) => number,
|
|
131
|
+
): number[];
|
|
132
|
+
interval<T>(
|
|
133
|
+
data: readonly T[],
|
|
134
|
+
statistic: (resample: readonly T[]) => number,
|
|
135
|
+
method: ConfidenceIntervalMethod,
|
|
136
|
+
): ConfidenceInterval;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
66
140
|
## Documentation
|
|
67
141
|
|
|
142
|
+
**Recipes**
|
|
143
|
+
|
|
144
|
+
- [Give the interval that a Python program gives](./docs/recipes/give-the-interval-that-a-python-program-gives.md)
|
|
145
|
+
- [Read an interval from resamples that you draw yourself](./docs/recipes/read-an-interval-from-resamples-you-draw.md)
|
|
146
|
+
|
|
147
|
+
**Decisions**
|
|
148
|
+
|
|
68
149
|
- [ADR 0001: one home for the percentile bootstrap that six places copied, reached through a workspace path](docs/adr/0001-one-home-for-the-percentile-bootstrap-that-six-places-copied.md)
|
|
69
150
|
- [ADR 0002: one home for the pairwise sum of NumPy that four places copied](docs/adr/0002-one-home-for-the-pairwise-sum-of-numpy-that-four-places-copied.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/statistics",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.44",
|
|
4
4
|
"description": "The percentile bootstrap, NumPy's quantile methods, and numpy.sum, numpy.mean and numpy.nanmean in JavaScript, to the last bit: resamples with a random generator that the caller gives, the percentile interval of their statistic, and NumPy's pairwise sum.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|