校对器/趋势

分析数据,尝试找到显著的趋势

0.1.0 2017-01-11 14:17 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:09:15 UTC


README

Latest Version on Packagist Software License Build Status Quality Score Coverage Status Total Downloads

分析数据,尝试找到显著的趋势。

简介

想象你在查看图表中的点,并希望画一条通过这些点代表其变化的直线。这就是趋势计算器所做的工作。它告诉你是否有一条通过这些点的直线以及其斜率。

An example of linear regression

此类从输入一系列时间数据点,进行回归分析,确定其统计显著性并返回趋势。

时间是自变量/解释变量,值是因变量/结果/目标变量。用最简单的话说

“值随时间如何变化?”

安装

使用 PHP 包管理器安装趋势计算器,Composer

composer require revisor/trend

使用方法

$trendCalculator = new TrendCalculator();

/**
 * $data is an array of arrays
 * In the inner arrays, keys are a time value in any unit (seconds, ie.
 * timestamp, microseconds, days, weeks...), the values are data values.
 * Multiple values for one point in time are allowed - maybe two events
 * occurred at one time.
 */
$data = [
    [1 => 9],
    [1 => 5],
    [2 => 12],
    [4 => 7]
];

/**
 * The resulting trend is a negative or positive float, or zero.
 * 
 * Values other than zero mean that there is a significant trend in the provided
 * data, and the trend goes down (for a negative number) or up (for a positive number).
 *
 * If the value is zero, it means that there is no significant trend.
 */
$trend = $trendCalculator->calculateTrend($data);

趋势的斜率通过 mcordingley/Regression 计算。你可以通过询问回归本身来获取更多关于数据的信息。

$regression = $trendCalculator->getRegression();
var_dump($regression->getStandardErrorCoefficients());

变更日志

请参阅 CHANGELOG 了解最近有哪些变化。

贡献

请参阅 CONTRIBUTING 了解详细信息。

鸣谢

许可证

MIT 许可证(MIT)。请参阅 许可证 了解更多信息。