@formant/ava 3.4.1-formant
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 +72 -0
- package/dist/ava.min.js +1 -0
- package/esm/advisor/advise-pipeline/advicesForChart.js +68 -0
- package/esm/advisor/advise-pipeline/data-to-advices.js +241 -0
- package/esm/advisor/advise-pipeline/index.js +1 -0
- package/esm/advisor/advise-pipeline/spec-mapping.js +500 -0
- package/esm/advisor/advisor.js +35 -0
- package/esm/advisor/constants.js +13 -0
- package/esm/advisor/index.js +2 -0
- package/esm/advisor/lint-pipeline/check-rules.js +43 -0
- package/esm/advisor/lint-pipeline/getChartType.js +109 -0
- package/esm/advisor/lint-pipeline/index.js +0 -0
- package/esm/advisor/lint-pipeline/lintRules.js +32 -0
- package/esm/advisor/ruler/index.js +74 -0
- package/esm/advisor/ruler/rules/aggregation-single-row.js +21 -0
- package/esm/advisor/ruler/rules/all-can-be-table.js +17 -0
- package/esm/advisor/ruler/rules/bar-series-qty.js +36 -0
- package/esm/advisor/ruler/rules/bar-without-axis-min.js +41 -0
- package/esm/advisor/ruler/rules/constants.js +6 -0
- package/esm/advisor/ruler/rules/data-check.js +40 -0
- package/esm/advisor/ruler/rules/data-field-qty.js +26 -0
- package/esm/advisor/ruler/rules/diff-pie-sector.js +33 -0
- package/esm/advisor/ruler/rules/index.js +68 -0
- package/esm/advisor/ruler/rules/landscape-or-portrait.js +40 -0
- package/esm/advisor/ruler/rules/limit-series.js +47 -0
- package/esm/advisor/ruler/rules/line-field-time-ordinal.js +25 -0
- package/esm/advisor/ruler/rules/no-redundant-field.js +32 -0
- package/esm/advisor/ruler/rules/nominal-enum-combinatorial.js +54 -0
- package/esm/advisor/ruler/rules/purpose-check.js +27 -0
- package/esm/advisor/ruler/rules/series-qty-limit.js +34 -0
- package/esm/advisor/ruler/rules/x-axis-line-fading.js +41 -0
- package/esm/advisor/ruler/types.js +1 -0
- package/esm/advisor/ruler/utils.js +54 -0
- package/esm/advisor/types.js +1 -0
- package/esm/advisor/utils/clone.js +32 -0
- package/esm/advisor/utils/compare.js +14 -0
- package/esm/advisor/utils/computeScore.js +25 -0
- package/esm/advisor/utils/deep-mix.js +76 -0
- package/esm/advisor/utils/hasSubset.js +3 -0
- package/esm/advisor/utils/index.js +8 -0
- package/esm/advisor/utils/inferDataType.js +70 -0
- package/esm/advisor/utils/intersects.js +3 -0
- package/esm/advisor/utils/isNil.js +4 -0
- package/esm/ckb/base.js +1310 -0
- package/esm/ckb/ckb.js +55 -0
- package/esm/ckb/constants.js +197 -0
- package/esm/ckb/i18n/index.js +23 -0
- package/esm/ckb/i18n/types.js +1 -0
- package/esm/ckb/i18n/zh-CN.js +525 -0
- package/esm/ckb/index.js +14 -0
- package/esm/ckb/types.js +1 -0
- package/esm/common/types.js +1 -0
- package/esm/data/analysis/field/index.js +336 -0
- package/esm/data/analysis/field/types.js +1 -0
- package/esm/data/analysis/graph/index.js +170 -0
- package/esm/data/analysis/graph/types.js +1 -0
- package/esm/data/analysis/index.js +1 -0
- package/esm/data/analysis/types.js +1 -0
- package/esm/data/dataset/field/baseFrame.js +76 -0
- package/esm/data/dataset/field/dataFrame.js +556 -0
- package/esm/data/dataset/field/index.js +3 -0
- package/esm/data/dataset/field/series.js +149 -0
- package/esm/data/dataset/field/types.js +1 -0
- package/esm/data/dataset/field/utils.js +58 -0
- package/esm/data/dataset/graph/index.js +186 -0
- package/esm/data/dataset/graph/types.js +1 -0
- package/esm/data/dataset/graph/utils.js +15 -0
- package/esm/data/dataset/index.js +1 -0
- package/esm/data/dataset/types.js +1 -0
- package/esm/data/index.js +5 -0
- package/esm/data/statistics/IQR.js +49 -0
- package/esm/data/statistics/base.js +248 -0
- package/esm/data/statistics/bayesian.js +25 -0
- package/esm/data/statistics/buishand-u.js +19 -0
- package/esm/data/statistics/caches.js +28 -0
- package/esm/data/statistics/cdf.js +25 -0
- package/esm/data/statistics/constants.js +12 -0
- package/esm/data/statistics/index.js +7 -0
- package/esm/data/statistics/lowess.js +80 -0
- package/esm/data/statistics/mannkendall-test.js +50 -0
- package/esm/data/statistics/maxabs.js +9 -0
- package/esm/data/statistics/pcorrtest.js +76 -0
- package/esm/data/statistics/pettitt-test.js +33 -0
- package/esm/data/statistics/quantile.js +56 -0
- package/esm/data/statistics/types.js +1 -0
- package/esm/data/statistics/vector.js +67 -0
- package/esm/data/statistics/window.js +55 -0
- package/esm/data/types.js +2 -0
- package/esm/data/utils/common.js +58 -0
- package/esm/data/utils/index.js +5 -0
- package/esm/data/utils/isType/constants.js +24 -0
- package/esm/data/utils/isType/index.js +2 -0
- package/esm/data/utils/isType/isDateString.js +104 -0
- package/esm/data/utils/isType/isType.js +78 -0
- package/esm/index.js +11 -0
- package/esm/insight/algorithms/base/compare.js +40 -0
- package/esm/insight/algorithms/categoryOutlier.js +4 -0
- package/esm/insight/algorithms/changePoint.js +10 -0
- package/esm/insight/algorithms/index.js +3 -0
- package/esm/insight/algorithms/trendDirection.js +4 -0
- package/esm/insight/chart/constants.js +25 -0
- package/esm/insight/chart/generator/homogeneous.js +70 -0
- package/esm/insight/chart/generator/index.js +2 -0
- package/esm/insight/chart/generator/insights.js +16 -0
- package/esm/insight/chart/index.js +4 -0
- package/esm/insight/chart/strategy/augmentedMarks/categoryOutlier.js +30 -0
- package/esm/insight/chart/strategy/augmentedMarks/changePoint.js +42 -0
- package/esm/insight/chart/strategy/augmentedMarks/correlation.js +6 -0
- package/esm/insight/chart/strategy/augmentedMarks/homogeneous.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/index.js +8 -0
- package/esm/insight/chart/strategy/augmentedMarks/lowVariance.js +23 -0
- package/esm/insight/chart/strategy/augmentedMarks/majority.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +82 -0
- package/esm/insight/chart/strategy/augmentedMarks/trend.js +26 -0
- package/esm/insight/chart/strategy/chart.js +45 -0
- package/esm/insight/chart/strategy/commonMarks/areaMark.js +12 -0
- package/esm/insight/chart/strategy/commonMarks/index.js +5 -0
- package/esm/insight/chart/strategy/commonMarks/intervalMark.js +14 -0
- package/esm/insight/chart/strategy/commonMarks/lineMark.js +34 -0
- package/esm/insight/chart/strategy/commonMarks/pointMark.js +17 -0
- package/esm/insight/chart/strategy/commonMarks/textMark.js +28 -0
- package/esm/insight/chart/strategy/index.js +4 -0
- package/esm/insight/chart/strategy/viewSpec.js +16 -0
- package/esm/insight/chart/types.js +1 -0
- package/esm/insight/chart/utils.js +4 -0
- package/esm/insight/constant.js +21 -0
- package/esm/insight/index.js +5 -0
- package/esm/insight/insights/checkers.js +97 -0
- package/esm/insight/insights/extractors/categoryOutlier.js +90 -0
- package/esm/insight/insights/extractors/changePoint.js +55 -0
- package/esm/insight/insights/extractors/correlation.js +38 -0
- package/esm/insight/insights/extractors/homogeneous.js +98 -0
- package/esm/insight/insights/extractors/lowVariance.js +49 -0
- package/esm/insight/insights/extractors/majority.js +66 -0
- package/esm/insight/insights/extractors/timeSeriesOutlier.js +61 -0
- package/esm/insight/insights/extractors/trend.js +49 -0
- package/esm/insight/insights/index.js +28 -0
- package/esm/insight/insights/util.js +77 -0
- package/esm/insight/narrative/factory.js +22 -0
- package/esm/insight/narrative/index.js +14 -0
- package/esm/insight/narrative/strategy/base.js +6 -0
- package/esm/insight/narrative/strategy/categoryOutlier.js +74 -0
- package/esm/insight/narrative/strategy/changePoint.js +52 -0
- package/esm/insight/narrative/strategy/commonness.js +45 -0
- package/esm/insight/narrative/strategy/correlation.js +51 -0
- package/esm/insight/narrative/strategy/exception.js +70 -0
- package/esm/insight/narrative/strategy/helpers.js +25 -0
- package/esm/insight/narrative/strategy/index.js +13 -0
- package/esm/insight/narrative/strategy/lowVariance.js +48 -0
- package/esm/insight/narrative/strategy/majority.js +62 -0
- package/esm/insight/narrative/strategy/timeSeriesOutlier.js +92 -0
- package/esm/insight/narrative/strategy/trend.js +57 -0
- package/esm/insight/pipeline/extract.js +236 -0
- package/esm/insight/pipeline/index.js +11 -0
- package/esm/insight/pipeline/insight.js +81 -0
- package/esm/insight/pipeline/preprocess.js +33 -0
- package/esm/insight/pipeline/specificInsight.js +71 -0
- package/esm/insight/pipeline/util.js +14 -0
- package/esm/insight/pipeline/visualize.js +41 -0
- package/esm/insight/types.js +1 -0
- package/esm/insight/utils/aggregate.js +87 -0
- package/esm/insight/utils/common.js +35 -0
- package/esm/ntv/generate/generateTextSpec.js +157 -0
- package/esm/ntv/generate/index.js +5 -0
- package/esm/ntv/generate/types.js +1 -0
- package/esm/ntv/generate/utils.js +86 -0
- package/esm/ntv/index.js +4 -0
- package/esm/ntv/schema/common.js +1 -0
- package/esm/ntv/schema/index.js +4 -0
- package/esm/ntv/schema/paragraph.js +1 -0
- package/esm/ntv/schema/phrase.js +52 -0
- package/esm/ntv/schema/structure.js +1 -0
- package/esm/ntv/types.js +1 -0
- package/esm/ntv/utils/index.js +1 -0
- package/esm/ntv/utils/isSpecType.js +58 -0
- package/esm/utils/arr2map.js +7 -0
- package/esm/utils/dataFormat.js +32 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/isType.js +14 -0
- package/lib/advisor/advise-pipeline/advicesForChart.d.ts +13 -0
- package/lib/advisor/advise-pipeline/advicesForChart.js +73 -0
- package/lib/advisor/advise-pipeline/data-to-advices.d.ts +22 -0
- package/lib/advisor/advise-pipeline/data-to-advices.js +245 -0
- package/lib/advisor/advise-pipeline/index.d.ts +1 -0
- package/lib/advisor/advise-pipeline/index.js +5 -0
- package/lib/advisor/advise-pipeline/spec-mapping.d.ts +14 -0
- package/lib/advisor/advise-pipeline/spec-mapping.js +504 -0
- package/lib/advisor/advisor.d.ts +18 -0
- package/lib/advisor/advisor.js +38 -0
- package/lib/advisor/constants.d.ts +1 -0
- package/lib/advisor/constants.js +16 -0
- package/lib/advisor/index.d.ts +2 -0
- package/lib/advisor/index.js +7 -0
- package/lib/advisor/lint-pipeline/check-rules.d.ts +4 -0
- package/lib/advisor/lint-pipeline/check-rules.js +47 -0
- package/lib/advisor/lint-pipeline/getChartType.d.ts +7 -0
- package/lib/advisor/lint-pipeline/getChartType.js +113 -0
- package/lib/advisor/lint-pipeline/index.d.ts +0 -0
- package/lib/advisor/lint-pipeline/index.js +0 -0
- package/lib/advisor/lint-pipeline/lintRules.d.ts +5 -0
- package/lib/advisor/lint-pipeline/lintRules.js +36 -0
- package/lib/advisor/ruler/index.d.ts +21 -0
- package/lib/advisor/ruler/index.js +80 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.d.ts +2 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.js +24 -0
- package/lib/advisor/ruler/rules/all-can-be-table.d.ts +2 -0
- package/lib/advisor/ruler/rules/all-can-be-table.js +20 -0
- package/lib/advisor/ruler/rules/bar-series-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-series-qty.js +39 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.js +44 -0
- package/lib/advisor/ruler/rules/constants.d.ts +6 -0
- package/lib/advisor/ruler/rules/constants.js +9 -0
- package/lib/advisor/ruler/rules/data-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-check.js +43 -0
- package/lib/advisor/ruler/rules/data-field-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-field-qty.js +29 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.d.ts +2 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.js +36 -0
- package/lib/advisor/ruler/rules/index.d.ts +19 -0
- package/lib/advisor/ruler/rules/index.js +71 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.d.ts +2 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.js +43 -0
- package/lib/advisor/ruler/rules/limit-series.d.ts +2 -0
- package/lib/advisor/ruler/rules/limit-series.js +50 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.d.ts +2 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.js +28 -0
- package/lib/advisor/ruler/rules/no-redundant-field.d.ts +2 -0
- package/lib/advisor/ruler/rules/no-redundant-field.js +35 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.d.ts +2 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.js +57 -0
- package/lib/advisor/ruler/rules/purpose-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/purpose-check.js +30 -0
- package/lib/advisor/ruler/rules/series-qty-limit.d.ts +2 -0
- package/lib/advisor/ruler/rules/series-qty-limit.js +37 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.d.ts +2 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.js +44 -0
- package/lib/advisor/ruler/types.d.ts +125 -0
- package/lib/advisor/ruler/types.js +2 -0
- package/lib/advisor/ruler/utils.d.ts +10 -0
- package/lib/advisor/ruler/utils.js +61 -0
- package/lib/advisor/types.d.ts +218 -0
- package/lib/advisor/types.js +4 -0
- package/lib/advisor/utils/clone.d.ts +2 -0
- package/lib/advisor/utils/clone.js +34 -0
- package/lib/advisor/utils/compare.d.ts +3 -0
- package/lib/advisor/utils/compare.js +17 -0
- package/lib/advisor/utils/computeScore.d.ts +7 -0
- package/lib/advisor/utils/computeScore.js +27 -0
- package/lib/advisor/utils/deep-mix.d.ts +2 -0
- package/lib/advisor/utils/deep-mix.js +78 -0
- package/lib/advisor/utils/hasSubset.d.ts +1 -0
- package/lib/advisor/utils/hasSubset.js +7 -0
- package/lib/advisor/utils/index.d.ts +5 -0
- package/lib/advisor/utils/index.js +19 -0
- package/lib/advisor/utils/inferDataType.d.ts +6 -0
- package/lib/advisor/utils/inferDataType.js +75 -0
- package/lib/advisor/utils/intersects.d.ts +1 -0
- package/lib/advisor/utils/intersects.js +7 -0
- package/lib/advisor/utils/isNil.d.ts +2 -0
- package/lib/advisor/utils/isNil.js +6 -0
- package/lib/ckb/base.d.ts +2 -0
- package/lib/ckb/base.js +1313 -0
- package/lib/ckb/ckb.d.ts +8 -0
- package/lib/ckb/ckb.js +59 -0
- package/lib/ckb/constants.d.ts +79 -0
- package/lib/ckb/constants.js +200 -0
- package/lib/ckb/i18n/index.d.ts +10 -0
- package/lib/ckb/i18n/index.js +27 -0
- package/lib/ckb/i18n/types.d.ts +52 -0
- package/lib/ckb/i18n/types.js +2 -0
- package/lib/ckb/i18n/zh-CN.d.ts +7 -0
- package/lib/ckb/i18n/zh-CN.js +528 -0
- package/lib/ckb/index.d.ts +4 -0
- package/lib/ckb/index.js +20 -0
- package/lib/ckb/types.d.ts +185 -0
- package/lib/ckb/types.js +2 -0
- package/lib/common/types.d.ts +14 -0
- package/lib/common/types.js +2 -0
- package/lib/data/analysis/field/index.d.ts +79 -0
- package/lib/data/analysis/field/index.js +355 -0
- package/lib/data/analysis/field/types.d.ts +99 -0
- package/lib/data/analysis/field/types.js +2 -0
- package/lib/data/analysis/graph/index.d.ts +28 -0
- package/lib/data/analysis/graph/index.js +178 -0
- package/lib/data/analysis/graph/types.d.ts +62 -0
- package/lib/data/analysis/graph/types.js +2 -0
- package/lib/data/analysis/index.d.ts +1 -0
- package/lib/data/analysis/index.js +5 -0
- package/lib/data/analysis/types.d.ts +1 -0
- package/lib/data/analysis/types.js +2 -0
- package/lib/data/dataset/field/baseFrame.d.ts +30 -0
- package/lib/data/dataset/field/baseFrame.js +78 -0
- package/lib/data/dataset/field/dataFrame.d.ts +35 -0
- package/lib/data/dataset/field/dataFrame.js +558 -0
- package/lib/data/dataset/field/index.d.ts +3 -0
- package/lib/data/dataset/field/index.js +8 -0
- package/lib/data/dataset/field/series.d.ts +18 -0
- package/lib/data/dataset/field/series.js +151 -0
- package/lib/data/dataset/field/types.d.ts +54 -0
- package/lib/data/dataset/field/types.js +2 -0
- package/lib/data/dataset/field/utils.d.ts +13 -0
- package/lib/data/dataset/field/utils.js +68 -0
- package/lib/data/dataset/graph/index.d.ts +18 -0
- package/lib/data/dataset/graph/index.js +188 -0
- package/lib/data/dataset/graph/types.d.ts +35 -0
- package/lib/data/dataset/graph/types.js +2 -0
- package/lib/data/dataset/graph/utils.d.ts +1 -0
- package/lib/data/dataset/graph/utils.js +19 -0
- package/lib/data/dataset/index.d.ts +1 -0
- package/lib/data/dataset/index.js +4 -0
- package/lib/data/dataset/types.d.ts +1 -0
- package/lib/data/dataset/types.js +4 -0
- package/lib/data/index.d.ts +5 -0
- package/lib/data/index.js +8 -0
- package/lib/data/statistics/IQR.d.ts +21 -0
- package/lib/data/statistics/IQR.js +53 -0
- package/lib/data/statistics/base.d.ts +106 -0
- package/lib/data/statistics/base.js +271 -0
- package/lib/data/statistics/bayesian.d.ts +5 -0
- package/lib/data/statistics/bayesian.js +30 -0
- package/lib/data/statistics/buishand-u.d.ts +7 -0
- package/lib/data/statistics/buishand-u.js +23 -0
- package/lib/data/statistics/caches.d.ts +13 -0
- package/lib/data/statistics/caches.js +33 -0
- package/lib/data/statistics/cdf.d.ts +7 -0
- package/lib/data/statistics/cdf.js +29 -0
- package/lib/data/statistics/constants.d.ts +5 -0
- package/lib/data/statistics/constants.js +15 -0
- package/lib/data/statistics/index.d.ts +7 -0
- package/lib/data/statistics/index.js +14 -0
- package/lib/data/statistics/lowess.d.ts +10 -0
- package/lib/data/statistics/lowess.js +87 -0
- package/lib/data/statistics/mannkendall-test.d.ts +15 -0
- package/lib/data/statistics/mannkendall-test.js +54 -0
- package/lib/data/statistics/maxabs.d.ts +5 -0
- package/lib/data/statistics/maxabs.js +13 -0
- package/lib/data/statistics/pcorrtest.d.ts +3 -0
- package/lib/data/statistics/pcorrtest.js +80 -0
- package/lib/data/statistics/pettitt-test.d.ts +9 -0
- package/lib/data/statistics/pettitt-test.js +38 -0
- package/lib/data/statistics/quantile.d.ts +16 -0
- package/lib/data/statistics/quantile.js +61 -0
- package/lib/data/statistics/types.d.ts +70 -0
- package/lib/data/statistics/types.js +2 -0
- package/lib/data/statistics/vector.d.ts +15 -0
- package/lib/data/statistics/vector.js +78 -0
- package/lib/data/statistics/window.d.ts +12 -0
- package/lib/data/statistics/window.js +60 -0
- package/lib/data/types.d.ts +2 -0
- package/lib/data/types.js +5 -0
- package/lib/data/utils/common.d.ts +26 -0
- package/lib/data/utils/common.js +67 -0
- package/lib/data/utils/index.d.ts +2 -0
- package/lib/data/utils/index.js +8 -0
- package/lib/data/utils/isType/constants.d.ts +15 -0
- package/lib/data/utils/isType/constants.js +27 -0
- package/lib/data/utils/isType/index.d.ts +2 -0
- package/lib/data/utils/isType/index.js +5 -0
- package/lib/data/utils/isType/isDateString.d.ts +18 -0
- package/lib/data/utils/isType/isDateString.js +111 -0
- package/lib/data/utils/isType/isType.d.ts +13 -0
- package/lib/data/utils/isType/isType.js +94 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +75 -0
- package/lib/insight/algorithms/base/compare.d.ts +14 -0
- package/lib/insight/algorithms/base/compare.js +45 -0
- package/lib/insight/algorithms/categoryOutlier.d.ts +4 -0
- package/lib/insight/algorithms/categoryOutlier.js +7 -0
- package/lib/insight/algorithms/changePoint.d.ts +10 -0
- package/lib/insight/algorithms/changePoint.js +13 -0
- package/lib/insight/algorithms/index.d.ts +3 -0
- package/lib/insight/algorithms/index.js +6 -0
- package/lib/insight/algorithms/trendDirection.d.ts +4 -0
- package/lib/insight/algorithms/trendDirection.js +7 -0
- package/lib/insight/chart/constants.d.ts +13 -0
- package/lib/insight/chart/constants.js +28 -0
- package/lib/insight/chart/generator/homogeneous.d.ts +3 -0
- package/lib/insight/chart/generator/homogeneous.js +75 -0
- package/lib/insight/chart/generator/index.d.ts +2 -0
- package/lib/insight/chart/generator/index.js +5 -0
- package/lib/insight/chart/generator/insights.d.ts +3 -0
- package/lib/insight/chart/generator/insights.js +20 -0
- package/lib/insight/chart/index.d.ts +4 -0
- package/lib/insight/chart/index.js +7 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.js +35 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.js +47 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.js +10 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.d.ts +8 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.js +24 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.js +28 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +87 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.js +31 -0
- package/lib/insight/chart/strategy/chart.d.ts +7 -0
- package/lib/insight/chart/strategy/chart.js +49 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.js +16 -0
- package/lib/insight/chart/strategy/commonMarks/index.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/index.js +13 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.js +18 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.js +38 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.js +21 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.js +32 -0
- package/lib/insight/chart/strategy/index.d.ts +4 -0
- package/lib/insight/chart/strategy/index.js +10 -0
- package/lib/insight/chart/strategy/viewSpec.d.ts +3 -0
- package/lib/insight/chart/strategy/viewSpec.js +20 -0
- package/lib/insight/chart/types.d.ts +60 -0
- package/lib/insight/chart/types.js +2 -0
- package/lib/insight/chart/utils.d.ts +3 -0
- package/lib/insight/chart/utils.js +8 -0
- package/lib/insight/constant.d.ts +12 -0
- package/lib/insight/constant.js +24 -0
- package/lib/insight/index.d.ts +6 -0
- package/lib/insight/index.js +13 -0
- package/lib/insight/insights/checkers.d.ts +16 -0
- package/lib/insight/insights/checkers.js +107 -0
- package/lib/insight/insights/extractors/categoryOutlier.d.ts +12 -0
- package/lib/insight/insights/extractors/categoryOutlier.js +95 -0
- package/lib/insight/insights/extractors/changePoint.d.ts +8 -0
- package/lib/insight/insights/extractors/changePoint.js +60 -0
- package/lib/insight/insights/extractors/correlation.d.ts +9 -0
- package/lib/insight/insights/extractors/correlation.js +43 -0
- package/lib/insight/insights/extractors/homogeneous.d.ts +4 -0
- package/lib/insight/insights/extractors/homogeneous.js +103 -0
- package/lib/insight/insights/extractors/lowVariance.d.ts +8 -0
- package/lib/insight/insights/extractors/lowVariance.js +54 -0
- package/lib/insight/insights/extractors/majority.d.ts +10 -0
- package/lib/insight/insights/extractors/majority.js +71 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.d.ts +2 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.js +65 -0
- package/lib/insight/insights/extractors/trend.d.ts +9 -0
- package/lib/insight/insights/extractors/trend.js +54 -0
- package/lib/insight/insights/index.d.ts +12 -0
- package/lib/insight/insights/index.js +32 -0
- package/lib/insight/insights/util.d.ts +13 -0
- package/lib/insight/insights/util.js +87 -0
- package/lib/insight/narrative/factory.d.ts +6 -0
- package/lib/insight/narrative/factory.js +25 -0
- package/lib/insight/narrative/index.d.ts +3 -0
- package/lib/insight/narrative/index.js +18 -0
- package/lib/insight/narrative/strategy/base.d.ts +9 -0
- package/lib/insight/narrative/strategy/base.js +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.d.ts +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.js +76 -0
- package/lib/insight/narrative/strategy/changePoint.d.ts +8 -0
- package/lib/insight/narrative/strategy/changePoint.js +54 -0
- package/lib/insight/narrative/strategy/commonness.d.ts +9 -0
- package/lib/insight/narrative/strategy/commonness.js +47 -0
- package/lib/insight/narrative/strategy/correlation.d.ts +8 -0
- package/lib/insight/narrative/strategy/correlation.js +53 -0
- package/lib/insight/narrative/strategy/exception.d.ts +10 -0
- package/lib/insight/narrative/strategy/exception.js +72 -0
- package/lib/insight/narrative/strategy/helpers.d.ts +5 -0
- package/lib/insight/narrative/strategy/helpers.js +31 -0
- package/lib/insight/narrative/strategy/index.d.ts +9 -0
- package/lib/insight/narrative/strategy/index.js +28 -0
- package/lib/insight/narrative/strategy/lowVariance.d.ts +8 -0
- package/lib/insight/narrative/strategy/lowVariance.js +50 -0
- package/lib/insight/narrative/strategy/majority.d.ts +8 -0
- package/lib/insight/narrative/strategy/majority.js +64 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.d.ts +8 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.js +94 -0
- package/lib/insight/narrative/strategy/trend.d.ts +8 -0
- package/lib/insight/narrative/strategy/trend.js +59 -0
- package/lib/insight/pipeline/extract.d.ts +13 -0
- package/lib/insight/pipeline/extract.js +243 -0
- package/lib/insight/pipeline/index.d.ts +2 -0
- package/lib/insight/pipeline/index.js +15 -0
- package/lib/insight/pipeline/insight.d.ts +10 -0
- package/lib/insight/pipeline/insight.js +86 -0
- package/lib/insight/pipeline/preprocess.d.ts +6 -0
- package/lib/insight/pipeline/preprocess.js +39 -0
- package/lib/insight/pipeline/specificInsight.d.ts +11 -0
- package/lib/insight/pipeline/specificInsight.js +79 -0
- package/lib/insight/pipeline/util.d.ts +5 -0
- package/lib/insight/pipeline/util.js +20 -0
- package/lib/insight/pipeline/visualize.d.ts +3 -0
- package/lib/insight/pipeline/visualize.js +46 -0
- package/lib/insight/types.d.ts +238 -0
- package/lib/insight/types.js +2 -0
- package/lib/insight/utils/aggregate.d.ts +7 -0
- package/lib/insight/utils/aggregate.js +93 -0
- package/lib/insight/utils/common.d.ts +3 -0
- package/lib/insight/utils/common.js +41 -0
- package/lib/ntv/generate/generateTextSpec.d.ts +9 -0
- package/lib/ntv/generate/generateTextSpec.js +160 -0
- package/lib/ntv/generate/index.d.ts +2 -0
- package/lib/ntv/generate/index.js +12 -0
- package/lib/ntv/generate/types.d.ts +58 -0
- package/lib/ntv/generate/types.js +2 -0
- package/lib/ntv/generate/utils.d.ts +29 -0
- package/lib/ntv/generate/utils.js +96 -0
- package/lib/ntv/index.d.ts +4 -0
- package/lib/ntv/index.js +10 -0
- package/lib/ntv/schema/common.d.ts +17 -0
- package/lib/ntv/schema/common.js +2 -0
- package/lib/ntv/schema/index.d.ts +4 -0
- package/lib/ntv/schema/index.js +7 -0
- package/lib/ntv/schema/paragraph.d.ts +34 -0
- package/lib/ntv/schema/paragraph.js +2 -0
- package/lib/ntv/schema/phrase.d.ts +70 -0
- package/lib/ntv/schema/phrase.js +55 -0
- package/lib/ntv/schema/structure.d.ts +18 -0
- package/lib/ntv/schema/structure.js +2 -0
- package/lib/ntv/types.d.ts +2 -0
- package/lib/ntv/types.js +2 -0
- package/lib/ntv/utils/index.d.ts +1 -0
- package/lib/ntv/utils/index.js +4 -0
- package/lib/ntv/utils/isSpecType.d.ts +17 -0
- package/lib/ntv/utils/isSpecType.js +76 -0
- package/lib/utils/arr2map.d.ts +1 -0
- package/lib/utils/arr2map.js +11 -0
- package/lib/utils/dataFormat.d.ts +11 -0
- package/lib/utils/dataFormat.js +35 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/isType.d.ts +4 -0
- package/lib/utils/isType.js +21 -0
- package/package.json +88 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IQR = void 0;
|
|
4
|
+
var compare_1 = require("../../insight/algorithms/base/compare");
|
|
5
|
+
function getQuartilePercentValue(array, percent) {
|
|
6
|
+
var product = percent * array.length;
|
|
7
|
+
var ceil = Math.ceil(product);
|
|
8
|
+
if (ceil === product) {
|
|
9
|
+
if (ceil === 0) {
|
|
10
|
+
return array[0];
|
|
11
|
+
}
|
|
12
|
+
if (ceil === array.length) {
|
|
13
|
+
return array[array.length - 1];
|
|
14
|
+
}
|
|
15
|
+
return (array[ceil - 1] + array[ceil]) / 2;
|
|
16
|
+
}
|
|
17
|
+
return array[ceil - 1];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param data
|
|
22
|
+
* @param params
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function IQR(data, params) {
|
|
26
|
+
var k = (params === null || params === void 0 ? void 0 : params.k) || 1.5;
|
|
27
|
+
var sorted = data.slice().sort(compare_1.ascending);
|
|
28
|
+
var q25 = getQuartilePercentValue(sorted, 0.25);
|
|
29
|
+
var q75 = getQuartilePercentValue(sorted, 0.75);
|
|
30
|
+
var iqr = q75 - q25;
|
|
31
|
+
var outliers = {
|
|
32
|
+
upper: {
|
|
33
|
+
threshold: 0,
|
|
34
|
+
indexes: [],
|
|
35
|
+
},
|
|
36
|
+
lower: {
|
|
37
|
+
threshold: 0,
|
|
38
|
+
indexes: [],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
outliers.lower.threshold = q25 - k * iqr;
|
|
42
|
+
outliers.upper.threshold = q75 + k * iqr;
|
|
43
|
+
data.forEach(function (item, index) {
|
|
44
|
+
if (item <= outliers.lower.threshold) {
|
|
45
|
+
outliers.lower.indexes.push(index);
|
|
46
|
+
}
|
|
47
|
+
else if (item >= outliers.upper.threshold) {
|
|
48
|
+
outliers.upper.indexes.push(index);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return outliers;
|
|
52
|
+
}
|
|
53
|
+
exports.IQR = IQR;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the minimum of the array.
|
|
3
|
+
* @param value - The array to process
|
|
4
|
+
*/
|
|
5
|
+
export declare function min(value: number[]): number;
|
|
6
|
+
/**
|
|
7
|
+
* Get the minimum index of the array.
|
|
8
|
+
* @param value - The array to process
|
|
9
|
+
*/
|
|
10
|
+
export declare function minIndex(value: number[]): number;
|
|
11
|
+
/**
|
|
12
|
+
* Get the maximum of the array.
|
|
13
|
+
* @param value - The array to process
|
|
14
|
+
*/
|
|
15
|
+
export declare function max(value: number[]): number;
|
|
16
|
+
/**
|
|
17
|
+
* Get the maximum index of the array.
|
|
18
|
+
* @param value - The array to process
|
|
19
|
+
*/
|
|
20
|
+
export declare function maxIndex(value: number[]): number;
|
|
21
|
+
/**
|
|
22
|
+
* Calculate the sum of the array.
|
|
23
|
+
* @param value - The array to process
|
|
24
|
+
*/
|
|
25
|
+
export declare function sum(value: number[]): number;
|
|
26
|
+
/**
|
|
27
|
+
* Calculate the mean of the array.
|
|
28
|
+
* @param value - The array to process
|
|
29
|
+
|
|
30
|
+
*/
|
|
31
|
+
export declare function mean(value: number[]): number;
|
|
32
|
+
/**
|
|
33
|
+
* Calculate the geometricMean of the array.
|
|
34
|
+
* @param value - The array to process
|
|
35
|
+
*/
|
|
36
|
+
export declare function geometricMean(value: number[]): number;
|
|
37
|
+
/**
|
|
38
|
+
* Calculate the harmonic mean of the array.
|
|
39
|
+
* @param value - The array to process
|
|
40
|
+
*/
|
|
41
|
+
export declare function harmonicMean(value: number[]): number;
|
|
42
|
+
/**
|
|
43
|
+
* Calculate the median of the array.
|
|
44
|
+
* @param value - The array to process
|
|
45
|
+
*/
|
|
46
|
+
export declare function median(value: number[], sorted?: boolean): number;
|
|
47
|
+
/**
|
|
48
|
+
* Calculate the quartile of the array.
|
|
49
|
+
* @param value - The array to process
|
|
50
|
+
* @param sorted - Whether it is sorted
|
|
51
|
+
*/
|
|
52
|
+
export declare function quartile(value: number[], sorted?: boolean): [number, number, number];
|
|
53
|
+
/**
|
|
54
|
+
* Calculate the quantile of the array.
|
|
55
|
+
* @param value - The array to process
|
|
56
|
+
* @param percent - percent
|
|
57
|
+
* @param sorted - Whether it is sorted
|
|
58
|
+
*/
|
|
59
|
+
export declare function quantile(value: number[], percent: number, sorted?: boolean): number;
|
|
60
|
+
/**
|
|
61
|
+
* Calculate the variance of the array.
|
|
62
|
+
* @param value - The array to process
|
|
63
|
+
*/
|
|
64
|
+
export declare function variance(value: number[]): number;
|
|
65
|
+
/**
|
|
66
|
+
* Calculate the standard deviation of the array.
|
|
67
|
+
* @param value - The array to process
|
|
68
|
+
*/
|
|
69
|
+
export declare function standardDeviation(value: number[]): number;
|
|
70
|
+
/**
|
|
71
|
+
* Calculate the coefficient of variance of the array.
|
|
72
|
+
* @param value - The array to process
|
|
73
|
+
*/
|
|
74
|
+
export declare function coefficientOfVariance(value: number[]): number;
|
|
75
|
+
/**
|
|
76
|
+
* Calculate the covariance of the array.
|
|
77
|
+
* @param x - variable x
|
|
78
|
+
* @param y - variable y
|
|
79
|
+
*/
|
|
80
|
+
export declare function covariance(x: number[], y: number[]): number;
|
|
81
|
+
/**
|
|
82
|
+
* Calculate the pearson correlation coefficient of two value.
|
|
83
|
+
* @param x - variable x
|
|
84
|
+
* @param y - variable y
|
|
85
|
+
*/
|
|
86
|
+
export declare function pearson(x: number[], y: number[]): number;
|
|
87
|
+
/**
|
|
88
|
+
* Calculate the counts of valid value in the array.
|
|
89
|
+
* @param value - The array to process
|
|
90
|
+
*/
|
|
91
|
+
export declare function valid(value: unknown[]): number;
|
|
92
|
+
/**
|
|
93
|
+
* Calculate the counts of missing value in the array.
|
|
94
|
+
* @param value - The array to process
|
|
95
|
+
*/
|
|
96
|
+
export declare function missing(value: unknown[]): number;
|
|
97
|
+
/**
|
|
98
|
+
* Calculate the counts of each distinct value in the array.
|
|
99
|
+
* @param value - The array to process
|
|
100
|
+
*/
|
|
101
|
+
export declare function valueMap(value: unknown[]): Record<string, number>;
|
|
102
|
+
/**
|
|
103
|
+
* Calculate the counts of distinct value in the array.
|
|
104
|
+
* @param value - The array to process
|
|
105
|
+
*/
|
|
106
|
+
export declare function distinct(value: unknown[]): number;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Statistical methods used internally by ava.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.distinct = exports.valueMap = exports.missing = exports.valid = exports.pearson = exports.covariance = exports.coefficientOfVariance = exports.standardDeviation = exports.variance = exports.quantile = exports.quartile = exports.median = exports.harmonicMean = exports.geometricMean = exports.mean = exports.sum = exports.maxIndex = exports.max = exports.minIndex = exports.min = void 0;
|
|
7
|
+
var tslib_1 = require("tslib");
|
|
8
|
+
var utils_1 = require("../utils");
|
|
9
|
+
var cache = tslib_1.__importStar(require("./caches"));
|
|
10
|
+
/**
|
|
11
|
+
* Get the minimum of the array.
|
|
12
|
+
* @param value - The array to process
|
|
13
|
+
*/
|
|
14
|
+
function min(value) {
|
|
15
|
+
var cachedValue = cache.get(value, 'min');
|
|
16
|
+
if (cachedValue !== undefined)
|
|
17
|
+
return cachedValue;
|
|
18
|
+
return cache.set(value, 'min', Math.min.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(value), false)));
|
|
19
|
+
}
|
|
20
|
+
exports.min = min;
|
|
21
|
+
function getMinIndex(value) {
|
|
22
|
+
var min = value[0];
|
|
23
|
+
var idx = 0;
|
|
24
|
+
for (var i = 0; i < value.length; i += 1) {
|
|
25
|
+
if (value[i] < min) {
|
|
26
|
+
idx = i;
|
|
27
|
+
min = value[i];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return idx;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the minimum index of the array.
|
|
34
|
+
* @param value - The array to process
|
|
35
|
+
*/
|
|
36
|
+
function minIndex(value) {
|
|
37
|
+
var cachedValue = cache.get(value, 'minIndex');
|
|
38
|
+
if (cachedValue !== undefined)
|
|
39
|
+
return cachedValue;
|
|
40
|
+
return cache.set(value, 'minIndex', getMinIndex(value));
|
|
41
|
+
}
|
|
42
|
+
exports.minIndex = minIndex;
|
|
43
|
+
/**
|
|
44
|
+
* Get the maximum of the array.
|
|
45
|
+
* @param value - The array to process
|
|
46
|
+
*/
|
|
47
|
+
function max(value) {
|
|
48
|
+
var cachedValue = cache.get(value, 'max');
|
|
49
|
+
if (cachedValue !== undefined)
|
|
50
|
+
return cachedValue;
|
|
51
|
+
return cache.set(value, 'max', Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(value), false)));
|
|
52
|
+
}
|
|
53
|
+
exports.max = max;
|
|
54
|
+
function getMaxIndex(value) {
|
|
55
|
+
var max = value[0];
|
|
56
|
+
var idx = 0;
|
|
57
|
+
for (var i = 0; i < value.length; i += 1) {
|
|
58
|
+
if (value[i] > max) {
|
|
59
|
+
idx = i;
|
|
60
|
+
max = value[i];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return idx;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get the maximum index of the array.
|
|
67
|
+
* @param value - The array to process
|
|
68
|
+
*/
|
|
69
|
+
function maxIndex(value) {
|
|
70
|
+
var cachedValue = cache.get(value, 'maxIndex');
|
|
71
|
+
if (cachedValue !== undefined)
|
|
72
|
+
return cachedValue;
|
|
73
|
+
return cache.set(value, 'maxIndex', getMaxIndex(value));
|
|
74
|
+
}
|
|
75
|
+
exports.maxIndex = maxIndex;
|
|
76
|
+
/**
|
|
77
|
+
* Calculate the sum of the array.
|
|
78
|
+
* @param value - The array to process
|
|
79
|
+
*/
|
|
80
|
+
function sum(value) {
|
|
81
|
+
var cachedValue = cache.get(value, 'sum');
|
|
82
|
+
if (cachedValue !== undefined)
|
|
83
|
+
return cachedValue;
|
|
84
|
+
return cache.set(value, 'sum', value.reduce(function (prev, current) { return current + prev; }, 0));
|
|
85
|
+
}
|
|
86
|
+
exports.sum = sum;
|
|
87
|
+
/**
|
|
88
|
+
* Calculate the mean of the array.
|
|
89
|
+
* @param value - The array to process
|
|
90
|
+
|
|
91
|
+
*/
|
|
92
|
+
function mean(value) {
|
|
93
|
+
return sum(value) / value.length;
|
|
94
|
+
}
|
|
95
|
+
exports.mean = mean;
|
|
96
|
+
/**
|
|
97
|
+
* Calculate the geometricMean of the array.
|
|
98
|
+
* @param value - The array to process
|
|
99
|
+
*/
|
|
100
|
+
function geometricMean(value) {
|
|
101
|
+
(0, utils_1.assert)(value.some(function (item) { return item > 0; }), 'Each item in value must greater than 0.');
|
|
102
|
+
var cachedValue = cache.get(value, 'geometricMean');
|
|
103
|
+
if (cachedValue !== undefined)
|
|
104
|
+
return cachedValue;
|
|
105
|
+
return cache.set(value, 'geometricMean', Math.pow(value.reduce(function (prev, curr) { return prev * curr; }, 1), (1 / value.length)));
|
|
106
|
+
}
|
|
107
|
+
exports.geometricMean = geometricMean;
|
|
108
|
+
/**
|
|
109
|
+
* Calculate the harmonic mean of the array.
|
|
110
|
+
* @param value - The array to process
|
|
111
|
+
*/
|
|
112
|
+
function harmonicMean(value) {
|
|
113
|
+
var base = Math.pow(2, 16);
|
|
114
|
+
var cachedValue = cache.get(value, 'harmonicMean');
|
|
115
|
+
if (cachedValue !== undefined)
|
|
116
|
+
return cachedValue;
|
|
117
|
+
return cache.set(value, 'harmonicMean', (base * value.length) / value.reduce(function (prev, curr) { return base / curr + prev; }, 0));
|
|
118
|
+
}
|
|
119
|
+
exports.harmonicMean = harmonicMean;
|
|
120
|
+
function sort(value) {
|
|
121
|
+
return value.sort(function (l, r) { return (l > r ? 1 : -1); });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Calculate the median of the array.
|
|
125
|
+
* @param value - The array to process
|
|
126
|
+
*/
|
|
127
|
+
function median(value, sorted) {
|
|
128
|
+
if (sorted === void 0) { sorted = false; }
|
|
129
|
+
var length = value.length;
|
|
130
|
+
var newArray = sorted ? value : sort(value);
|
|
131
|
+
if (length % 2 === 1)
|
|
132
|
+
return newArray[(length - 1) / 2];
|
|
133
|
+
return (newArray[length / 2 - 1] + newArray[length / 2]) / 2;
|
|
134
|
+
}
|
|
135
|
+
exports.median = median;
|
|
136
|
+
/**
|
|
137
|
+
* Calculate the quartile of the array.
|
|
138
|
+
* @param value - The array to process
|
|
139
|
+
* @param sorted - Whether it is sorted
|
|
140
|
+
*/
|
|
141
|
+
function quartile(value, sorted) {
|
|
142
|
+
if (sorted === void 0) { sorted = false; }
|
|
143
|
+
(0, utils_1.assert)(value.length >= 3, 'The length of value cannot be less than 3.');
|
|
144
|
+
var length = value.length;
|
|
145
|
+
var newArray = sorted ? value : sort(value);
|
|
146
|
+
var Q2 = median(newArray, true);
|
|
147
|
+
var Q1;
|
|
148
|
+
var Q3;
|
|
149
|
+
if (length % 2 === 1) {
|
|
150
|
+
Q1 = median(newArray.slice(0, (length - 1) / 2), true);
|
|
151
|
+
Q3 = median(newArray.slice((length + 1) / 2), true);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
Q1 = median(newArray.slice(0, length / 2), true);
|
|
155
|
+
Q3 = median(newArray.slice(length / 2), true);
|
|
156
|
+
}
|
|
157
|
+
return [Q1, Q2, Q3];
|
|
158
|
+
}
|
|
159
|
+
exports.quartile = quartile;
|
|
160
|
+
/**
|
|
161
|
+
* Calculate the quantile of the array.
|
|
162
|
+
* @param value - The array to process
|
|
163
|
+
* @param percent - percent
|
|
164
|
+
* @param sorted - Whether it is sorted
|
|
165
|
+
*/
|
|
166
|
+
function quantile(value, percent, sorted) {
|
|
167
|
+
if (sorted === void 0) { sorted = false; }
|
|
168
|
+
(0, utils_1.assert)(percent > 0 && percent < 100, 'The percent cannot be between (0, 100).');
|
|
169
|
+
var newArray = sorted ? value : sort(value);
|
|
170
|
+
var index = Math.ceil((value.length * percent) / 100) - 1;
|
|
171
|
+
return newArray[index];
|
|
172
|
+
}
|
|
173
|
+
exports.quantile = quantile;
|
|
174
|
+
/**
|
|
175
|
+
* Calculate the variance of the array.
|
|
176
|
+
* @param value - The array to process
|
|
177
|
+
*/
|
|
178
|
+
function variance(value) {
|
|
179
|
+
var m = mean(value);
|
|
180
|
+
var cachedValue = cache.get(value, 'variance');
|
|
181
|
+
if (cachedValue !== undefined)
|
|
182
|
+
return cachedValue;
|
|
183
|
+
return cache.set(value, 'variance', value.reduce(function (prev, curr) { return prev + Math.pow((curr - m), 2); }, 0) / value.length);
|
|
184
|
+
}
|
|
185
|
+
exports.variance = variance;
|
|
186
|
+
/**
|
|
187
|
+
* Calculate the standard deviation of the array.
|
|
188
|
+
* @param value - The array to process
|
|
189
|
+
*/
|
|
190
|
+
function standardDeviation(value) {
|
|
191
|
+
return Math.sqrt(variance(value));
|
|
192
|
+
}
|
|
193
|
+
exports.standardDeviation = standardDeviation;
|
|
194
|
+
/**
|
|
195
|
+
* Calculate the coefficient of variance of the array.
|
|
196
|
+
* @param value - The array to process
|
|
197
|
+
*/
|
|
198
|
+
function coefficientOfVariance(value) {
|
|
199
|
+
var stdev = standardDeviation(value);
|
|
200
|
+
var arrayMean = mean(value);
|
|
201
|
+
return stdev / arrayMean;
|
|
202
|
+
}
|
|
203
|
+
exports.coefficientOfVariance = coefficientOfVariance;
|
|
204
|
+
/**
|
|
205
|
+
* Calculate the covariance of the array.
|
|
206
|
+
* @param x - variable x
|
|
207
|
+
* @param y - variable y
|
|
208
|
+
*/
|
|
209
|
+
function covariance(x, y) {
|
|
210
|
+
(0, utils_1.assert)(x.length === y.length, 'The x and y must has same length.');
|
|
211
|
+
var exy = mean(x.map(function (item, i) { return item * y[i]; }));
|
|
212
|
+
return exy - mean(x) * mean(y);
|
|
213
|
+
}
|
|
214
|
+
exports.covariance = covariance;
|
|
215
|
+
/**
|
|
216
|
+
* Calculate the pearson correlation coefficient of two value.
|
|
217
|
+
* @param x - variable x
|
|
218
|
+
* @param y - variable y
|
|
219
|
+
*/
|
|
220
|
+
function pearson(x, y) {
|
|
221
|
+
var cov = covariance(x, y);
|
|
222
|
+
var dx = standardDeviation(x);
|
|
223
|
+
var dy = standardDeviation(y);
|
|
224
|
+
return cov / (dx * dy);
|
|
225
|
+
}
|
|
226
|
+
exports.pearson = pearson;
|
|
227
|
+
/**
|
|
228
|
+
* Calculate the counts of valid value in the array.
|
|
229
|
+
* @param value - The array to process
|
|
230
|
+
*/
|
|
231
|
+
function valid(value) {
|
|
232
|
+
var count = 0;
|
|
233
|
+
for (var i = 0; i < value.length; i += 1) {
|
|
234
|
+
if (value[i])
|
|
235
|
+
count += 1;
|
|
236
|
+
}
|
|
237
|
+
return count;
|
|
238
|
+
}
|
|
239
|
+
exports.valid = valid;
|
|
240
|
+
/**
|
|
241
|
+
* Calculate the counts of missing value in the array.
|
|
242
|
+
* @param value - The array to process
|
|
243
|
+
*/
|
|
244
|
+
function missing(value) {
|
|
245
|
+
return value.length - valid(value);
|
|
246
|
+
}
|
|
247
|
+
exports.missing = missing;
|
|
248
|
+
/**
|
|
249
|
+
* Calculate the counts of each distinct value in the array.
|
|
250
|
+
* @param value - The array to process
|
|
251
|
+
*/
|
|
252
|
+
function valueMap(value) {
|
|
253
|
+
var data = {};
|
|
254
|
+
value.forEach(function (v) {
|
|
255
|
+
var vStr = "".concat(v);
|
|
256
|
+
if (data[vStr])
|
|
257
|
+
data[vStr] += 1;
|
|
258
|
+
else
|
|
259
|
+
data[vStr] = 1;
|
|
260
|
+
});
|
|
261
|
+
return data;
|
|
262
|
+
}
|
|
263
|
+
exports.valueMap = valueMap;
|
|
264
|
+
/**
|
|
265
|
+
* Calculate the counts of distinct value in the array.
|
|
266
|
+
* @param value - The array to process
|
|
267
|
+
*/
|
|
268
|
+
function distinct(value) {
|
|
269
|
+
return Object.keys(valueMap(value)).length;
|
|
270
|
+
}
|
|
271
|
+
exports.distinct = distinct;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bayesian = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var bayesian_changepoint_1 = tslib_1.__importDefault(require("bayesian-changepoint"));
|
|
6
|
+
var pettitt_test_1 = require("./pettitt-test");
|
|
7
|
+
function breakpointVerifier(next, prev) {
|
|
8
|
+
if (Math.abs(next.data - prev.data) >= 1) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Bayesian Online Changepoint Detection
|
|
15
|
+
*/
|
|
16
|
+
function bayesian(series) {
|
|
17
|
+
if (series === void 0) { series = []; }
|
|
18
|
+
var detection = new bayesian_changepoint_1.default({
|
|
19
|
+
breakpointVerifier: breakpointVerifier,
|
|
20
|
+
chunkSize: series.length,
|
|
21
|
+
iteratee: function (t) { return t; },
|
|
22
|
+
});
|
|
23
|
+
detection.exec(series);
|
|
24
|
+
var result = detection.breakPoints().map(function (breakPoint) { return ({
|
|
25
|
+
index: breakPoint.index,
|
|
26
|
+
significance: 1 - (0, pettitt_test_1.calcPValue)(series, breakPoint.index),
|
|
27
|
+
}); });
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
exports.bayesian = bayesian;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buishandUTest = void 0;
|
|
4
|
+
var lodash_1 = require("lodash");
|
|
5
|
+
var __1 = require("..");
|
|
6
|
+
var window_1 = require("./window");
|
|
7
|
+
/**
|
|
8
|
+
* Buishad U statistics test
|
|
9
|
+
*/
|
|
10
|
+
function buishandUTest(data) {
|
|
11
|
+
var n = data === null || data === void 0 ? void 0 : data.length;
|
|
12
|
+
var meanValue = (0, lodash_1.mean)(data);
|
|
13
|
+
var Sk = data.map(function (_, index) { return (0, lodash_1.sum)(data.slice(0, index + 1)) - meanValue * (index + 1); });
|
|
14
|
+
var U = (0, lodash_1.sumBy)(Sk.slice(0, n - 1), function (item) { return Math.pow(item, 2); }) / (n * (n + 1));
|
|
15
|
+
var Smax = (0, __1.maxabs)(Sk);
|
|
16
|
+
var maxIndex = Sk.findIndex(function (item) { return item === Smax; });
|
|
17
|
+
return {
|
|
18
|
+
uValue: U,
|
|
19
|
+
index: maxIndex,
|
|
20
|
+
significance: 1 - (0, window_1.calcPValue)(data, maxIndex),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.buishandUTest = buishandUTest;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache the value for target and key.
|
|
3
|
+
* @param target - target
|
|
4
|
+
* @param key - key
|
|
5
|
+
* @param value - value
|
|
6
|
+
*/
|
|
7
|
+
export declare function set<T>(target: any[], key: string, value: T): T;
|
|
8
|
+
/**
|
|
9
|
+
* Get the cached value for target and key.
|
|
10
|
+
* @param target - target
|
|
11
|
+
* @param key - key
|
|
12
|
+
*/
|
|
13
|
+
export declare function get<T>(target: any[], key: string): T | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get = exports.set = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Cache some statistics results to improve performance.
|
|
6
|
+
*/
|
|
7
|
+
var CACHES = new WeakMap();
|
|
8
|
+
/**
|
|
9
|
+
* Cache the value for target and key.
|
|
10
|
+
* @param target - target
|
|
11
|
+
* @param key - key
|
|
12
|
+
* @param value - value
|
|
13
|
+
*/
|
|
14
|
+
function set(target, key, value) {
|
|
15
|
+
if (!CACHES.get(target)) {
|
|
16
|
+
CACHES.set(target, new Map());
|
|
17
|
+
}
|
|
18
|
+
CACHES.get(target).set(key, value);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
exports.set = set;
|
|
22
|
+
/**
|
|
23
|
+
* Get the cached value for target and key.
|
|
24
|
+
* @param target - target
|
|
25
|
+
* @param key - key
|
|
26
|
+
*/
|
|
27
|
+
function get(target, key) {
|
|
28
|
+
var cache = CACHES.get(target);
|
|
29
|
+
if (!cache)
|
|
30
|
+
return undefined;
|
|
31
|
+
return cache.get(key);
|
|
32
|
+
}
|
|
33
|
+
exports.get = get;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates the cumulative distribution function (CDF) for a normal distribution at a value x
|
|
3
|
+
* - Reference to equation 26.2.17 in https://personal.math.ubc.ca/~cbm/aands/abramowitz_and_stegun.pdf
|
|
4
|
+
* @param mu mean
|
|
5
|
+
* @param sigma standard deviation
|
|
6
|
+
* */
|
|
7
|
+
export declare const cdf: (x: number, mu?: number, sigma?: number) => number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cdf = void 0;
|
|
4
|
+
var lodash_1 = require("lodash");
|
|
5
|
+
/**
|
|
6
|
+
* Evaluates the cumulative distribution function (CDF) for a normal distribution at a value x
|
|
7
|
+
* - Reference to equation 26.2.17 in https://personal.math.ubc.ca/~cbm/aands/abramowitz_and_stegun.pdf
|
|
8
|
+
* @param mu mean
|
|
9
|
+
* @param sigma standard deviation
|
|
10
|
+
* */
|
|
11
|
+
var cdf = function (x, mu, sigma) {
|
|
12
|
+
if (mu === void 0) { mu = 0; }
|
|
13
|
+
if (sigma === void 0) { sigma = 1; }
|
|
14
|
+
if (sigma < 0 || [x, mu, sigma].some(function (value) { return (0, lodash_1.isNil)(value); }))
|
|
15
|
+
return NaN;
|
|
16
|
+
// transfer to standard normal distribution
|
|
17
|
+
var normalX = Math.abs((x - mu) / sigma);
|
|
18
|
+
/** probability density function of the standard normal distribution */
|
|
19
|
+
var Zx = (1 / Math.sqrt(2 * Math.PI)) * Math.exp((-1 * Math.pow(normalX, 2)) / 2);
|
|
20
|
+
/**
|
|
21
|
+
* - use approximate elementary functional algorithm, error less than 4.5e-4
|
|
22
|
+
* @todo add document explaining the derivation process
|
|
23
|
+
* */
|
|
24
|
+
var t = 1 / (1 + 0.33267 * normalX);
|
|
25
|
+
// error less than 1e-5
|
|
26
|
+
var Px = 1 - Zx * (0.4361836 * t - 0.1201676 * Math.pow(t, 2) + 0.937298 * Math.pow(t, 3));
|
|
27
|
+
return x > mu ? Px : 1 - Px;
|
|
28
|
+
};
|
|
29
|
+
exports.cdf = cdf;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_PCORRTEST_OPTIONS = exports.DEFAULT_LOWESS_OPTIONS = void 0;
|
|
4
|
+
/** default options in LOWESS */
|
|
5
|
+
exports.DEFAULT_LOWESS_OPTIONS = {
|
|
6
|
+
f: 2 / 3,
|
|
7
|
+
nSteps: 3,
|
|
8
|
+
delta: null,
|
|
9
|
+
};
|
|
10
|
+
/** default options in LOWESS */
|
|
11
|
+
exports.DEFAULT_PCORRTEST_OPTIONS = {
|
|
12
|
+
alpha: 0.05,
|
|
13
|
+
alternative: 'two-sided',
|
|
14
|
+
rho: 0,
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pcorrtest = exports.maxabs = exports.cdf = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./base"), exports);
|
|
6
|
+
var cdf_1 = require("./cdf");
|
|
7
|
+
Object.defineProperty(exports, "cdf", { enumerable: true, get: function () { return cdf_1.cdf; } });
|
|
8
|
+
var maxabs_1 = require("./maxabs");
|
|
9
|
+
Object.defineProperty(exports, "maxabs", { enumerable: true, get: function () { return maxabs_1.maxabs; } });
|
|
10
|
+
tslib_1.__exportStar(require("./quantile"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./lowess"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./vector"), exports);
|
|
13
|
+
var pcorrtest_1 = require("./pcorrtest");
|
|
14
|
+
Object.defineProperty(exports, "pcorrtest", { enumerable: true, get: function () { return pcorrtest_1.pcorrtest; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LowessOptions, LowessOutput } from './types';
|
|
2
|
+
export declare const tricubeWeightFunction: (x: number) => number;
|
|
3
|
+
export declare const bisquareWeightFunction: (x: number) => number;
|
|
4
|
+
export declare const weightedLinearRegression: (x: number[], y: number[], w: number[]) => number[][];
|
|
5
|
+
/**
|
|
6
|
+
* Locally weighted regression
|
|
7
|
+
* - General idea: perform weighted linear regression on localized subsets of the data point by point to calculate fitted value.
|
|
8
|
+
* - Reference: William S. Cleveland. Robust Locally Weighted Regression and Smoothing Scatterplots. Journal of the American Statistical Association. 1979. Vol. 74(368):829-836.
|
|
9
|
+
* */
|
|
10
|
+
export declare const lowess: (x: number[], y: number[], options?: LowessOptions) => LowessOutput;
|