algorithm - 检测我的数字异常增长/下降的算法
问题描述
我有一个数据集,其中包含在过去 30 天内访问我网站页面的访客编号,它看起来像这样:
Page 1: [1,2,66,2,2,7,8]
Page 2: [3,5,8,3,7,11,45]
页面的总量是巨大的。我想应用一种算法来检测在此期间突然增长、峰值或下降的页面。有没有一种算法可以让我做到这一点?
解决方案
int Q = 20; //Q should be the difference
//between two pages that should be
//considered a spike
for (int i = 0; i < pages.length; i++){
page p = pages[i];
for (int j = 0; j < p.visitors.length - 1; j++){
if(p.visitors[j] >= p.visitors[j+1] + Q){
print("Page " + i + " has spike in day " + j);
}
else if(p.visitors[j] + Q <= p.visitors[j+1] + Q){
print("Page " + i + " has spike in day " + (j+1));
}
}
}
推荐阅读
- azureservicebus - MassTransit 命令消费者创建主题。它是否正确?
- react-native - 如何用曲线做出反应原生液体动画
- spring-boot - 在请求参数“_csrf”或标头“X-CSRF-TOKEN”上发现无效的 CSRF 令牌“null”.. Spring-boot
- excel - 根据另一个单元格值将单元格值分组到范围
- java - Auth0 升级到 Node8
- mongodb-atlas - 将 Google Cloud Run 连接到 MongoDB Atlas
- python - zip 文件正在压缩到默认项目目录文件夹而不是文件目录
- node.js - 环回电子邮件连接器不发送电子邮件
- google-apps-script - 如何自动复制超链接,使其链接到相同的重复页面而不是 Google 表格中的原始页面?
- hl7-fhir - Sending data (non-standard) headers in FHIR request