我在 R 中使用 optim() 来解决涉及积分的可能性时遇到了一些麻烦。我收到一条错误消息,指出“优化错误(par = c(0.1,0.1),LLL,方法=“L-BFGS-B”,较低= c(0,:L-BFGS-B需要'fn的有限值'"。下面是我的代码:
s1=c(1384,1,1219,1597,2106,145,87,1535,290,1752,265,588,1188,160,745,237,479,39,99,56,1503,158,916,651,1064,166,635,19,553,51,79,155,85,1196,142,108,325
,135,28,422,1032,1018,128,787,1704,307,854,6,896,902)
LLL=function (par) {
integrand1 <- function(x){ (x-s1[i]+1)*dgamma(x, shape=par[1], rate=par[2]) }
integrand2 <- function(x){ (-x+s1[i]+1)*dgamma(x, shape=par[1],rate=par[2]) }
likelihood = vector()
for(i in 1:length(s1)) {likelihood[i] =
log( integrate(integrand1,lower=s1[i]-1,upper=s1[i])$value+ integrate(integrand2,lower=s1[i],upper=s1[i]+1)$value )
}
like= -sum(likelihood)
return(like)
}
optim(par=c(0.1,0.1),LLL,method="L-BFGS-B", lower=c(0,0))
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助。
最好的事物,
元明
如何从virtual file. 我目前正在使用这种方式
BufferedReader br = new BufferedReader(new InputStreamReader(virtualFile.getInputStream()));
String currentLine;
StringBuilder stringBuilder = new StringBuilder();
while ((currentLine = br.readLine()) != null) {
stringBuilder.append(currentLine);
stringBuilder.append("\n");
}
} catch (IOException e1) {
e1.printStackTrace();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我打印stringbuilder.
我想做一个时间序列聚类任务。假设我们有四个数据 (t1~t4)。
t1={1,1,1,1,1,1,1}
t2={10,10,10,10,10,10,10}
t3={100,100,100,100,100,100,100}
t4 = {1,5,9,13,17,21,25}
Run Code Online (Sandbox Code Playgroud)
在这里,我在这个例子背后的意图是我想把 t1、t2、t3 组合在一起,因为它的形状是一条恒定的线。但是,t4 看起来像上升线,所以它应该在其他组中。
但是,如果我使用 DTW(python mlpy 包)计算 t1 和其他人之间的距离,我得到的结果如下:
t1-t1: 0 (absolutely)
t1-t2: 63
t1-t3: 693
t1-t4: 84
Run Code Online (Sandbox Code Playgroud)
我们可以看到,t1-t3 之间的距离远大于 t1-t4 之间的距离。我猜是因为 t3 的幅度幅度比其他幅度大得多。
在这种情况下,在适应 DTW 之前对每个时间序列数据使用 min-max 归一化(即 0 到 1 归一化)是个好方法吗?换句话说,使 t1, t2, t3 为 {0,0,0,0,0,0,0},t4 为 {0, 0,17,...., 1}?然后,DTW 根据我的需要返回结果。
很快,我想知道在 DTW 之前规范化任务是否合适。我是 DTW 的新手,很抱歉打扰您的基本问题!:)
var form = nlapiCreateForm("Process Order Items");
var locField = form.addField('custpage_locationlist', 'select', 'Location', 'location').setMandatory(true);
if(locationId != '')
locField.setDefaultValue(locationId);
var vendorField = form.addField('custpage_vendorlist', 'select', 'Vendor', 'vendor').setMandatory(true);
if(vendorId != '')
vendorField.setDefaultValue(vendorId);
form.addField('custpage_incitemnoprefvendor', 'checkbox', 'Include Items With No Preferred Vendor');
form.addField('custpage_incitemvendornopref', 'checkbox', 'Include Items Where Vendor is Not Preferred').setDisplayType('disabled');
var parentField = form.addField('custpage_parentitems', 'select', 'Parent Item', 'inventoryitem');
if(parentId != '')
parentField.setDefaultValue(parentId);
form.addField('custpage_minimunqty', 'integer', 'Minimum Quantity');
form.addField('custpage_tobeprinted', 'checkbox', 'To Be Printed');
form.addField('custpage_tobemailed', 'checkbox', 'To Be Mailed');
form.addField('custpage_tobefaxed', 'checkbox', 'To Be Faxed');
form.addField('custpage_total', 'float', 'Total').setDisplayType('inline');
var …Run Code Online (Sandbox Code Playgroud) 我需要GET来自服务的数据.我正在传递一堆ID.
id存储在以逗号分隔的文件中
示例:cat id_file
1,2,3,4,5,6,7,8,9,10,.....10000.
Run Code Online (Sandbox Code Playgroud)
文件中有数千个ID.
在我的shell脚本中我使用
id_list=$(cat id_file)
curl -H "Authorization: Bearer $token" -X GET "http://prk.xyx.com/tpt/abc/v2/dce_info?Id=$id_list&mpId=0" > op_data.json
Run Code Online (Sandbox Code Playgroud)
curl命令失败并显示错误 "/usr/bin/curl: Argument list too long".
现在POST我们可以指定卷曲@filename.我们可以为获取请求做些什么吗?
我想知道如何从特定输入文本字段获取值.有许多文本字段具有相同的名称和相同的类具有不同的值,每个输入有1个按钮.如何通过单击每个特定按钮从每个字段中获取值.使用Javascript或Jquery?请指导我.
<input type="hidden" name="myvalue" class="form-control input_text" value="aaa"/>
<input type="button" class="clickme" value="Get Value" />
<input type="hidden" name="myvalue" class="form-control input_text" value="bbb"/>
<input type="button" class="clickme" value="Get Value" />
<input type="hidden" name="myvalue" class="form-control input_text" value="ccc"/>
<input type="button" class="clickme" value="Get Value" />
<input type="hidden" name="myvalue" class="form-control input_text" value="ddd"/>
<input type="button" class="clickme" value="Get Value" />
<input type="hidden" name="myvalue" class="form-control input_text" value="eee"/>
<input type="button" class="clickme" value="Get Value" />Run Code Online (Sandbox Code Playgroud)
bash ×1
curl ×1
html ×1
intellij-14 ×1
javascript ×1
jquery ×1
netsuite ×1
optimization ×1
parsing ×1
r ×1
shell ×1
time-series ×1
unix ×1