diff --git a/site/docs/api/data/statistics.en.md b/site/docs/api/data/statistics.en.md index d4053336..fcbe58df 100644 --- a/site/docs/api/data/statistics.en.md +++ b/site/docs/api/data/statistics.en.md @@ -27,9 +27,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { min } from '@antv/ava'; -stats.min([1, 2, 3, 201, 999, 4, 5, 10]); +min([1, 2, 3, 201, 999, 4, 5, 10]); // 1 ``` @@ -50,9 +50,32 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { max } from '@antv/ava'; -stats.max([1, 2, 3, 201, 999, 4, 5, 10]); +max([1, 2, 3, 201, 999, 4, 5, 10]); +// 999 +``` + +## maxabs + +Calculate the maximum absolute value of array. + +***Parameters*** + +**array** Raw array data _required_ + +Type `number[]` + +***Return value*** + +`number` + +***Usage*** + +```ts +import { maxabs } from '@antv/ava'; + +maxabs([1, 2, 3, -201, -999, 4, 5, 10]); // 999 ``` @@ -73,9 +96,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { sum } from '@antv/ava'; -stats.sum([1, 2, 3, 201, 999, 4, 5, 10]); +sum([1, 2, 3, 201, 999, 4, 5, 10]); // 1225 ``` @@ -102,9 +125,9 @@ Default `false` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { median } from '@antv/ava'; -stats.median([1, 2, 3, 201, 999, 4, 5, 10]); +median([1, 2, 3, 201, 999, 4, 5, 10]); // 4.5 ``` @@ -131,9 +154,9 @@ Default `false` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { quartile } from '@antv/ava'; -stats.quartile([1, 2, 3, 201, 999, 4, 5, 10]); +quartile([1, 2, 3, 201, 999, 4, 5, 10]); // [ 2.5, 4.5, 105.5 ] ``` @@ -164,9 +187,9 @@ Default `false` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { quantile } from '@antv/ava'; -stats.quantile([1, 2, 3, 201, 999, 4, 5, 10], 75); +quantile([1, 2, 3, 201, 999, 4, 5, 10], 75); // 10 ``` @@ -187,9 +210,9 @@ type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { mean } from '@antv/ava'; -stats.mean([1, 2, 3, 201, 999, 4, 5, 10]); +mean([1, 2, 3, 201, 999, 4, 5, 10]); // 153.125 ``` @@ -210,9 +233,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { geometricMean } from '@antv/ava'; -stats.geometricMean([1, 2, 3, 201, 999, 4, 5, 10]); +geometricMean([1, 2, 3, 201, 999, 4, 5, 10]); // 11.162021352303842 ``` @@ -233,9 +256,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { harmonicMean } from '@antv/ava'; -stats.harmonicMean([1, 2, 3, 201, 999, 4, 5, 10]); +harmonicMean([1, 2, 3, 201, 999, 4, 5, 10]); // 3.34824774196937 ``` @@ -256,9 +279,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { variance } from '@antv/ava'; -stats.variance([1, 2, 3, 201, 999, 4, 5, 10]); +variance([1, 2, 3, 201, 999, 4, 5, 10]); // 106372.359375 ``` @@ -279,9 +302,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { standardDeviation } from '@antv/ava'; -stats.standardDeviation([1, 2, 3, 201, 999, 4, 5, 10]); +standardDeviation([1, 2, 3, 201, 999, 4, 5, 10]); // 326.1477569676051 ``` @@ -302,9 +325,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { coefficientOfVariance } from '@antv/ava'; -stats.coefficientOfVariance([1, 2, 3, 201, 999, 4, 5, 10]); +coefficientOfVariance([1, 2, 3, 201, 999, 4, 5, 10]); // 2.1299445352986455 ``` @@ -329,9 +352,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { covariance } from '@antv/ava'; -stats.covariance([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); +covariance([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); // 324526.3125 ``` @@ -356,9 +379,9 @@ Type `number[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { pearson } from '@antv/ava'; -stats.pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); +pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); // 0.8863724626851197 ``` @@ -379,9 +402,9 @@ Type `any[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { valid } from '@antv/ava'; -stats.valid([1, 2, NaN, 201, undefined, 4, 5, null]); +valid([1, 2, NaN, 201, undefined, 4, 5, null]); // 5 ``` @@ -402,9 +425,9 @@ Type `any[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { missing } from '@antv/ava'; -stats.missing([1, 2, NaN, 201, undefined, 4, 5, null]); +missing([1, 2, NaN, 201, undefined, 4, 5, null]); // 3 ``` @@ -425,9 +448,9 @@ type `any[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { valueMap } from '@antv/ava'; -stats.valueMap([1, 2, 3, 201, 999, 4, 5, 10]); +valueMap([1, 2, 3, 201, 999, 4, 5, 10]); // { '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '10': 1, '201': 1, '999': 1 } ``` @@ -448,293 +471,8 @@ type `any[]` ***Usage*** ```ts -import { statistics as stats } from '@antv/ava'; +import { distinct } from '@antv/ava'; -stats.distinct([1, 2, 3, 201, 999, 4, 5, 10]); +distinct([1, 2, 3, 201, 999, 4, 5, 10]); // 8 ``` - -## minBy - -Calculate the minimum value of the specified field of the array. - -***Parameters*** - -**array** Raw array data _required_ - -Type `any[]` - -**measure** Calculate the specified field _required_ - -Type `string` - -***Return value*** - -`number` - -***Usage*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.minBy(objects, 'n'); -// 1 -``` - -## maxBy - -Calculate the maximum value of the specified field of the array. - -***Parameters*** - -**array** Raw array data _required_ - -Type `any[]` - -**measure** Calculate the specified field _required_. - -Type `string` - -***Return value*** - -`number` - -***Usage*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.maxBy(objects, 'n'); -// 2 -``` - -## sumBy - -Calculate the sum of the values of the specified fields of the array. - -***Parameters*** - -**array** Raw array data _required_ - -Type `any[]` - -**measure** Calculate the sum of the specified fields _required_. - -Type `string` - -***Return value*** - -`number` - -***Usage*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.sumBy(objects, 'n'); -// 3 -``` - -## meanBy - -Calculate the average number of the specified fields in the array. - -***Parameters*** - -**array** Raw array data _required_ - -type `any[]` - -**measure** Calculate the specified field _required_ - -Type `string` - -***Return value*** - -`number` - - -***Usage*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.meanBy(objects, 'n'); -// 1.5 -``` - -## countBy - -Calculate the total count of the specified field of the array. - -***Parameters*** - -**array** Raw array data _required_ - -Type `any[]` - -**measure** Calculate the specified field _required_. - -Type `string` - -***Return value*** - -`number` - -***Usage*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.countBy(objects, 'n'); -// 2 -``` - -## groupBy - -Group the array objects by field. - -***Parameters*** - -**array** Raw array data _required_ - -type `any[]` - -**measure** Grouping of specified fields _required_ - -type `string` - -***Return value*** - -`any[]` - -***Usage*** - -```ts -import { statistics as stats } from '@antv/ava'; - - -const objects = [ - { - 'dimension': 'color', - 'measure': 'height' - }, { - 'dimension': 'map', - 'measure': 'height' - }, { - 'dimension': 'data', - 'measure': 'weight' - } -]; - -stats.groupBy(objects, 'measure'); -// { -// 'height': [ -// { -// 'dimension': 'color', -// 'measure': 'height' -// }, { -// 'dimension': 'map', -// 'measure': 'height' -// } -// ], -// 'weight': [ -// { -// 'dimension': 'data', -// 'measure': 'weight' -// } -// ] -// } -``` - -## aggregate - -Aggregate the array objects by the specified dimensions and fields. - -***Parameters*** - -**array** Raw array data _required_ - -type `any[]` - -**dimension** Aggregates the specified dimension _required_ - -Type `string` - -**measure** Aggregates the specified fields _required_ - -Type `string` - -**aggregateMethod** Aggregate method _optional_ - -Type ``AggregateMethod`, defaults to ``SUM` - -```sign -type AggregateMethod = 'SUM' | 'COUNT' | 'MAX' | 'MIN' | 'MEAN'; -``` - -**seriesField** Aggregate the specified sequence _optional_ - -Type `string` - -***Return value*** - -`any[]` - -***Usage*** - - -Type `string` - -***Return value*** - -`any[]` - -***Usage*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [ - { - 'dim': 1, - 'n': 1 - }, { - 'dim': 2, - 'n': 2, - 'm': 2 - }, { - 'dim': 1, - 'n': 3, - 'k': 3 - } -]; - -const dimensionName = 'dim'; - -const measureName = 'n'; - -stats.aggregate(objects, dimensionName, measureName); -// [ -// { -// 'dim': 1, -// 'n': 1 -// }, -// { -// 'dim': 2, -// 'n': 5 -// } -// ] -``` - - diff --git a/site/docs/api/data/statistics.zh.md b/site/docs/api/data/statistics.zh.md index 6be3405b..41c92c90 100644 --- a/site/docs/api/data/statistics.zh.md +++ b/site/docs/api/data/statistics.zh.md @@ -25,9 +25,9 @@ data 的数学统计模块 `statistics`,支持最大值、最小值、方差 ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { min } from '@antv/ava'; -stats.min([1, 2, 3, 201, 999, 4, 5, 10]); +min([1, 2, 3, 201, 999, 4, 5, 10]); // 1 ``` @@ -48,9 +48,32 @@ stats.min([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { max } from '@antv/ava'; -stats.max([1, 2, 3, 201, 999, 4, 5, 10]); +max([1, 2, 3, 201, 999, 4, 5, 10]); +// 999 +``` + +## maxabs + +计算数组中绝对值最大的数值。 + +***参数*** + +**array** 原数组数据 _必选_ + +类型 `number[]` + +***返回值*** + +`number` + +***用法*** + +```ts +import { maxabs } from '@antv/ava'; + +maxabs([1, 2, 3, -201, -999, 4, 5, 10]); // 999 ``` @@ -71,9 +94,9 @@ stats.max([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { sum } from '@antv/ava'; -stats.sum([1, 2, 3, 201, 999, 4, 5, 10]); +sum([1, 2, 3, 201, 999, 4, 5, 10]); // 1225 ``` @@ -100,9 +123,9 @@ stats.sum([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { median } from '@antv/ava'; -stats.median([1, 2, 3, 201, 999, 4, 5, 10]); +median([1, 2, 3, 201, 999, 4, 5, 10]); // 4.5 ``` @@ -129,9 +152,9 @@ stats.median([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { quartile } from '@antv/ava'; -stats.quartile([1, 2, 3, 201, 999, 4, 5, 10]); +quartile([1, 2, 3, 201, 999, 4, 5, 10]); // [ 2.5, 4.5, 105.5 ] ``` @@ -162,9 +185,9 @@ stats.quartile([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { quantile } from '@antv/ava'; -stats.quantile([1, 2, 3, 201, 999, 4, 5, 10], 75); +quantile([1, 2, 3, 201, 999, 4, 5, 10], 75); // 10 ``` @@ -185,9 +208,9 @@ stats.quantile([1, 2, 3, 201, 999, 4, 5, 10], 75); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { mean } from '@antv/ava'; -stats.mean([1, 2, 3, 201, 999, 4, 5, 10]); +mean([1, 2, 3, 201, 999, 4, 5, 10]); // 153.125 ``` @@ -208,9 +231,9 @@ stats.mean([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { geometricMean } from '@antv/ava'; -stats.geometricMean([1, 2, 3, 201, 999, 4, 5, 10]); +geometricMean([1, 2, 3, 201, 999, 4, 5, 10]); // 11.162021352303842 ``` @@ -231,9 +254,9 @@ stats.geometricMean([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { harmonicMean } from '@antv/ava'; -stats.harmonicMean([1, 2, 3, 201, 999, 4, 5, 10]); +harmonicMean([1, 2, 3, 201, 999, 4, 5, 10]); // 3.34824774196937 ``` @@ -254,9 +277,9 @@ stats.harmonicMean([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { variance } from '@antv/ava'; -stats.variance([1, 2, 3, 201, 999, 4, 5, 10]); +variance([1, 2, 3, 201, 999, 4, 5, 10]); // 106372.359375 ``` @@ -277,9 +300,9 @@ stats.variance([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { standardDeviation } from '@antv/ava'; -stats.standardDeviation([1, 2, 3, 201, 999, 4, 5, 10]); +standardDeviation([1, 2, 3, 201, 999, 4, 5, 10]); // 326.1477569676051 ``` @@ -300,9 +323,9 @@ stats.standardDeviation([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { coefficientOfVariance } from '@antv/ava'; -stats.coefficientOfVariance([1, 2, 3, 201, 999, 4, 5, 10]); +coefficientOfVariance([1, 2, 3, 201, 999, 4, 5, 10]); // 2.1299445352986455 ``` @@ -327,9 +350,9 @@ stats.coefficientOfVariance([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { covariance } from '@antv/ava'; -stats.covariance([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); +covariance([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); // 324526.3125 ``` @@ -354,9 +377,9 @@ stats.covariance([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { pearson } from '@antv/ava'; -stats.pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); +pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); // 0.8863724626851197 ``` @@ -377,9 +400,9 @@ stats.pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 21 ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { valid } from '@antv/ava'; -stats.valid([1, 2, NaN, 201, undefined, 4, 5, null]); +valid([1, 2, NaN, 201, undefined, 4, 5, null]); // 5 ``` @@ -400,9 +423,9 @@ stats.valid([1, 2, NaN, 201, undefined, 4, 5, null]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { missing } from '@antv/ava'; -stats.missing([1, 2, NaN, 201, undefined, 4, 5, null]); +missing([1, 2, NaN, 201, undefined, 4, 5, null]); // 3 ``` @@ -423,9 +446,9 @@ stats.missing([1, 2, NaN, 201, undefined, 4, 5, null]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { valueMap } from '@antv/ava'; -stats.valueMap([1, 2, 3, 201, 999, 4, 5, 10]); +valueMap([1, 2, 3, 201, 999, 4, 5, 10]); // { '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '10': 1, '201': 1, '999': 1 } ``` @@ -446,282 +469,8 @@ stats.valueMap([1, 2, 3, 201, 999, 4, 5, 10]); ***用法*** ```ts -import { statistics as stats } from '@antv/ava'; +import { distinct } from '@antv/ava'; -stats.distinct([1, 2, 3, 201, 999, 4, 5, 10]); +distinct([1, 2, 3, 201, 999, 4, 5, 10]); // 8 ``` - -## minBy - -计算数组指定字段的最小值。 - -***参数*** - -**array** 原数组数据 _必选_ - -类型 `any[]` - -**measure** 计算指定字段 _必选_ - -类型 `string` - -***返回值*** - -`number` - -***用法*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.minBy(objects, 'n'); -// 1 -``` - -## maxBy - -计算数组指定字段的最大值。 - -***参数*** - -**array** 原数组数据 _必选_ - -类型 `any[]` - -**measure** 计算指定字段 _必选_ - -类型 `string` - -***返回值*** - -`number` - -***用法*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.maxBy(objects, 'n'); -// 2 -``` - -## sumBy - -计算数组指定字段值之和。 - -***参数*** - -**array** 原数组数据 _必选_ - -类型 `any[]` - -**measure** 计算指定字段 _必选_ - -类型 `string` - -***返回值*** - -`number` - -***用法*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.sumBy(objects, 'n'); -// 3 -``` - -## meanBy - -计算数组指定字段平均数。 - -***参数*** - -**array** 原数组数据 _必选_ - -类型 `any[]` - -**measure** 计算指定字段 _必选_ - -类型 `string` - -***返回值*** - -`number` - -***用法*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.meanBy(objects, 'n'); -// 1.5 -``` - -## countBy - -计算数组指定字段总计数。 - -***参数*** - -**array** 原数组数据 _必选_ - -类型 `any[]` - -**measure** 计算指定字段 _必选_ - -类型 `string` - -***返回值*** - -`number` - -***用法*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [{ 'n': 1 }, { 'n': 2 }]; - -stats.countBy(objects, 'n'); -// 2 -``` - -## groupBy - -将数组对象按字段分组。 - -***参数*** - -**array** 原数组数据 _必选_ - -类型 `any[]` - -**measure** 分组指定字段 _必选_ - -类型 `string` - -***返回值*** - -`any[]` - -***用法*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [ - { - 'dimension': 'color', - 'measure': 'height' - }, { - 'dimension': 'map', - 'measure': 'height' - }, { - 'dimension': 'data', - 'measure': 'weight' - } -]; - -stats.groupBy(objects, 'measure'); -// { -// 'height': [ -// { -// 'dimension': 'color', -// 'measure': 'height' -// }, { -// 'dimension': 'map', -// 'measure': 'height' -// } -// ], -// 'weight': [ -// { -// 'dimension': 'data', -// 'measure': 'weight' -// } -// ] -// } -``` - -## aggregate - -将数组对象按指定维度和字段聚合。 - -***参数*** - -**array** 原数组数据 _必选_ - -类型 `any[]` - -**dimension** 聚合指定维度 _必选_ - -类型 `string` - -**measure** 聚合指定字段 _必选_ - -类型 `string` - -**aggregateMethod** 聚合方法 _可选_ - -类型 `AggregateMethod`,默认为 `SUM` - -```sign -type AggregateMethod = 'SUM' | 'COUNT' | 'MAX' | 'MIN' | 'MEAN'; -``` - -**seriesField** 聚合指定序列 _可选_ - -类型 `string` - -***返回值*** - -`any[]` - -***用法*** - -```ts -import { statistics as stats } from '@antv/ava'; - -const objects = [ - { - 'dim': 1, - 'n': 1 - }, { - 'dim': 2, - 'n': 2, - 'm': 2 - }, { - 'dim': 1, - 'n': 3, - 'k': 3 - } -]; - -const dimensionName = 'dim'; - -const measureName = 'n'; - -stats.aggregate(objects, dimensionName, measureName); -// [ -// { -// 'dim': 1, -// 'n': 1 -// }, -// { -// 'dim': 2, -// 'n': 5 -// } -// ] -``` - - diff --git a/site/docs/guide/data/intro.en.md b/site/docs/guide/data/intro.en.md index f551c55b..dbd84a43 100644 --- a/site/docs/guide/data/intro.en.md +++ b/site/docs/guide/data/intro.en.md @@ -141,18 +141,18 @@ df.info(); ### statistics ```ts -import { statistics as stats } from '@antv/ava'; +import { min, variance, pearson } from '@antv/ava'; /** Calculate minimum */ -stats.min([1, 2, 3, 201, 999, 4, 5, 10]); +min([1, 2, 3, 201, 999, 4, 5, 10]); // 1 /** Calculate variance */ -stats.variance([1, 2, 3, 201, 999, 4, 5, 10]); +variance([1, 2, 3, 201, 999, 4, 5, 10]); // 106372.359375 /** Calculate Pearson correlation coefficient */ -stats.pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); +pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); // 0.8863724626851197 ``` diff --git a/site/docs/guide/data/intro.zh.md b/site/docs/guide/data/intro.zh.md index a5c3502a..6825a0ae 100644 --- a/site/docs/guide/data/intro.zh.md +++ b/site/docs/guide/data/intro.zh.md @@ -141,18 +141,18 @@ df.info(); ### statistics ```ts -import { statistics as stats } from '@antv/ava'; +import { min, variance, pearson } from '@antv/ava'; /** 计算最小值 */ -stats.min([1, 2, 3, 201, 999, 4, 5, 10]); +min([1, 2, 3, 201, 999, 4, 5, 10]); // 1 /** 计算方差 */ -stats.variance([1, 2, 3, 201, 999, 4, 5, 10]); +variance([1, 2, 3, 201, 999, 4, 5, 10]); // 106372.359375 /** 计算皮尔逊系数 */ -stats.pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); +pearson([1, 2, 3, 201, 999, 4, 5, 10], [12, 22, 23, 2201, 2999, 24, 25, 210]); // 0.8863724626851197 ```