问题标签 [accumulate]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1173 浏览

php - 自动售货机程序php

所以我在 php 上做这个程序。这是一个简单的自动售货机程序,有 3 张图片。

逻辑:在 $total 变量中累积每次点击图像的价格。然后,点击显示总价,它应该显示总价。

然而,我的只显示一个流行音乐的价格。当我单击每个图像两次时,它只显示一个流行音乐的价格,第一个。?

这是我到目前为止所拥有的:

有什么想法吗?我打算把静态放在 $total 上?非常感谢。

0 投票
3 回答
104 浏览

c++ - 累积没有给出我的向量的正确总和

我有这个问题:

nCabCombo 的输出是 45,而它应该是 55,由于某种原因,累积函数没有添加我的计数器向量索引 11 处的 10。有人可以告诉我我在这里做错了什么吗?谢谢!

0 投票
1 回答
1425 浏览

r - vegan accumulation curve predictions

I'm having a matrix of plants(rows) and pollinators(columns) and interaction frequencies within (converted to 0 (no interaction) and 1 (interaction/s present) for this analysis). I'm using the vegan package and have produced a species accumulation curve.

I now would like to predict how many new pollinator species I would be likely to find with additional plant sampling but can't figure in what format I have to include "newdata" within the predict command. I have tried empty rows and rows with zeros within the matrix but was not able to get results. This is the code I've used for the prediction:

The error message:

The error message does not change if I specify: interpolation = c("linear") or "spline".

Could anyone help please?

0 投票
1 回答
29 浏览

mysql - How to make accumulative count based on date in MySQL?

I have the following table "testfinal"and would like to make it look like table "testfinal1" with accumulative sum based on orderdate.

testfinal

testfinal1

Now my code is as follows but it doesn't work

I think the problem is the term orderdate is not specified.

0 投票
3 回答
282 浏览

python - 一个点的向量的累积和

我有一个向量列表、一个标量列表和一个由元组表示的起点。

我有一个函数可以将“k 次”向量添加到一个点。

我想获得折线上的点列表,这样:

我想过使用itertools.accumulate,但func参数必须是两个参数的函数。有任何想法吗 ?

0 投票
1 回答
497 浏览

c++ - C++ 使用 std::accumulate 计算不正确的标准差

我使用以下代码来计算标准偏差:

std::accumulate4在它应该返回时返回:

此外,印刷(y - mean) * (y - mean)提供:

那么,它为什么不返回0 + 4 + 4呢?

0 投票
1 回答
298 浏览

java - 基于时间算子的累积/收集

我正在尝试编写一个基于时间运算符收集/累积值的规则。

这是我最初的规则,它设法使两个持续时间重叠。

我要创建的规则的想法是查看足球比赛中球员的持续时间是否存在任何集体重叠。我想看看场上最多 9 名球员中是否有任何一名球员以事件变量中指定为字符串的速度范围移动,这些速度都同时重叠。

我已经尝试了一些关于累积和收集的事情,但是在这些事件发生时如何收集它们并将它们返回到规则的右侧以便它们可以打印到标准输出时遇到了困难。

请帮忙。

谢谢。

0 投票
3 回答
57 浏览

php - 当PHP中关联数组中的另一个键的值相同时,如何总结不同键的值?

请参考 PHP 中的以下数组:

在这里,我想计算他在每个特定位置花费的总时间,即time_spent如果 keylocation相同,则累积 key 的值。然后将其记录在一个新的关联数组(比如$place_array)中,其中的值与键locationtotal_time.

所以输出数组应该是

0 投票
1 回答
175 浏览

wso2cep - WSO2CEP:从 siddhi 查询中的流中获取先前的事件值

我一直在使用以下siddhi query来获取每分钟的事件数;ts 作为时间戳(字符串)和 ftp_requests 作为计数(int)。

如果我想在每个新值中添加 ftp_requests 的先前值以获取每个新请求的累积请求数,需要进行哪些更改?siddhi 中是否有任何功能可以从已发布的流中获取先前的事件值?

0 投票
1 回答
2384 浏览

java - Drools - Drools 6 中的 ClassCastException

我在 Eclipse 中有一个非常简单的 Drools 项目,可以正常运行,但是当我打开或单击我的 .drl 文件时,Eclipse 中会弹出以下错误:

发生了错误。有关详细信息,请参阅错误日志。org.drools.core.base.accumulators.BigDecimalSumAccumulateFunction 不能转换为 org.drools.runtime.rule.AccumulateFunction

当我点击 OK 并再次运行程序时,它仍然运行良好。每当我从 .drl 文件中单击并重新单击时,都会再次弹出错误。Eclipse 日志具有以下堆栈跟踪:

!ENTRY org.eclipse.ui.workbench 4 2 2016-08-25 23:35:24.144

!MESSAGE 从插件调用代码时出现问题:“org.eclipse.ui.workbench”。

!STACK 0 java.lang.ClassCastException: org.drools.core.base.accumulators.BigDecimalSumAccumulateFunction 不能在 org.drools.compiler.PackageBuilderConfiguration.loadAccumulateFunction(PackageBuilderConfiguration.java:530) 中转换为 org.drools.runtime.rule.AccumulateFunction在 org.drools.compiler.PackageBuilderConfiguration.buildAccumulateFunctionsMap(PackageBuilderConfiguration.java:479) 在 org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:194) 在 org.drools.compiler.PackageBuilderConfiguration.(PackageBuilderConfiguration.java:170)在 org.drools.eclipse.DroolsEclipsePlugin.generateParsedResource(DroolsEclipsePlugin.java:612) 在 org.drools.eclipse.DroolsEclipsePlugin.parseResource(DroolsEclipsePlugin.java:515) 在 org.drools.eclipse.editors.outline。RuleContentOutlinePage.initRules(RuleContentOutlinePage.java:279) at org.drools.eclipse.editors.outline.RuleContentOutlinePage.update(RuleContentOutlinePage.java:159) at org.drools.eclipse.editors.outline.RuleContentOutlinePage.createControl(RuleContentOutlinePage.java: 133)

在此处查看整个堆栈跟踪:http: //pastebin.com/hJK1Cs03

我的程序:

.drl 根本不需要任何规则来引发错误。在编译时或运行时没有错误。

我将 Drools 6.[0-4].0.Final 作为单独的 Drools 运行时安装,除了 Drools 6.0.0.Final 之外的每个版本我都看到了这个问题。我正在运行 Java7。我也可以使用 Drools 5.5.0.Final 运行一个非常相似的程序,没有任何问题。

鉴于程序以预期的行为成功,并且即使 .drl 为空也会引发错误,我倾向于认为这是 Eclipse 和我的项目设置的问题。有人对如何解决这个问题有任何指导吗?提前致谢。