gpt4 book ai didi

math - MySQL Math - 是否可以计算查询中的相关性?

转载 作者:可可西里 更新时间:2023-11-01 06:31:45 27 4
gpt4 key购买 nike

在 MySQL (5.1) 数据库表中,有数据表示:

  • 用户执行任务需要多长时间
  • 用户在任务中处理了多少项目。

MySQL 是否支持关联数据,还是我需要使用 PHP/C# 来计算?

我在哪里可以找到计算相关性的好公式(我上次这样做已经有很长时间了)?

最佳答案

下面是样本相关系数的粗略实现,如下所述:

Wikipedia - Correlation and Dependence

create table sample( x float not null, y float not null );
insert into sample values (1, 10), (2, 4), (3, 5), (6,17);

select @ax := avg(x),
@ay := avg(y),
@div := (stddev_samp(x) * stddev_samp(y))
from sample;

select sum( ( x - @ax ) * (y - @ay) ) / ((count(x) -1) * @div) from sample;
+---------------------------------------------------------+
| sum( ( x - @ax ) * (y - @ay) ) / ((count(x) -1) * @div) |
+---------------------------------------------------------+
| 0.700885077729073 |
+---------------------------------------------------------+

关于math - MySQL Math - 是否可以计算查询中的相关性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2457645/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com