同步模式?大家好,
我正在努力与JMP / JSL的异步部分。现在我明白你可以使用“Run Formulas()”在使用之前强制评估一个公式,但是我遇到了与其他函数类似的问题:
使用该值时,可能不正确。这非常危险!
是否存在“强制同步模式”,其中JSL按指令进行指令并系统地等待一个完成,然后再移动到下一个?
我当前问题的示例,我从一个表(dt)中的行选择(selRows)中提取值以填充另一个表(sumdt)中的行:
thisCol = Column(sumdt, thisName||"_Q10");
valueSet = Column(dt, colList[i])[selRows];
thisValue = Quantile(0.10, valueSet);
thisCol[] = thisValue;
thisCol = Column(sumdt, thisName||"_Q25");
thisValue = Quantile (0.25, valueSet);
thisCol[] = thisValue;
thisCol = Column(sumdt, thisName||"_Q50");
thisValue = Quantile (0.50, valueSet);
thisCol[] = thisValue;
thisCol = Column(sumdt, thisName||"_Q75");
thisValue = Quantile (0.75, valueSet);
thisCol[] = thisValue;
thisCol = Column(sumdt, thisName||"_Q90");
thisValue = Quantile (0.90, valueSet);
thisCol[] = thisValue;这适用于有时!但有时候,sumdt列中的所有数据都是相同的值,有时候根本就没有任何数据。
我知道有人建议使用wait(0)命令,但是我读到有人说这也不是保证。
那么如何确保计算完成?
谢谢!
Re:同步模式?AAARGH!
我发现了问题,那是...... 传入的数据!
我想一些文件上的一些列的名称与开头的主要名称相同,只是有一个不同的数字(我剥离),但只有一个值,所以有统计数据!
我对这种误导性深表歉意!我还是学习了很好的练习,所以我很感激。
谢谢大家的支持!
Re:同步模式?回答自己:
不,这不是统计函数,而是我获取值的方式。这组数字出错了。
Re:同步模式?我修复了两个,并没有改变我的问题。
我不再相信这是一场竞争。它非常系统化,并且在同一组数据上发生在同一个地方。我试图改变项目顺序或将范围缩小到一个项目,将std dev作为第一个计算,更改元素顺序,并且我仍然在输出中有相同的确切数字错误或缺失。
12.1统计函数是否存在已知错误?
Re:同步模式?- 除掉当前数据表(dt); 并在需要时使用显式dt。如果在JSL运行时单击表,则当前数据数据可能会更改。
- 除非设置当前行,否则不要使用列[/ *空括号而没有下标* /]。空[]表示“当前行”。通常不需要空括号。您的示例可能需要显式行下标。
Re:同步模式?你好,我们又见面了,
感谢您的回答和见解。
不幸的是,我仍然有同样的问题:缺少值,输出集中的重复值(从Q10到Mean,缺少StdDev)。
我尝试过多种方法。我在旁边做了一个下标来“手动”检查一些异常值,它们很好。
我添加了许多“等待”声明。
我完全没有想法!
这是脚本(几乎全部,删除了一些有关列的存在的验证,等等,它足够大):
Names Default To Here(1);
dt = Current Data Table();
colNames = dt << Get Column Names (String);
Summarize(itemsList = by("Item"));
binsList = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D"};
colNamesSum = sumdt << Get Column Names (String);
For (k=1, k <= Nitems(itemsList), k++,
itemID = itemsList[k];
dt << Select All Rows << Exclude(0);
dt << Select Where (dt:Item == itemID);
itemRows = dt << Get Selected Rows;
prodID = Right(Column (dt, "proc_id")[itemRows[1]],4);
lotID = Regex(Column(dt, "lot_id")[itemRows[1]], "\d{6}");
show(lotID,itemID);
checkDup = sumdt << Get Rows Where (:Lot == lotID & :Item == itemID);
If(NRows(checkDup) == 0,
newIt = 1;
show(newIt);
sumdt << AddRows(1);
Column(sumdt, "Test Date")[] = Column(dt, "finish_t")[itemRows[1]];
Column(sumdt, "Item")[] = itemID;
Column(sumdt, "N ")[] = NRow(itemRows);
Column(sumdt, "Product")[] = prodId;
Column(sumdt, "Lot")[] = lotID;
dt << Invert Row Selection << Exclude(1);
Current Data Table(dt);
Summarize(bins = by(:SBIN_NUM), countTable = count());
dt << Select All Rows << Exclude(0);
Current Data Table(sumdt);
For (i=1, i <= Nitems(binsList), i++,
binPos = Contains(bins, binsList[i]);
Column(sumdt, "Bin"||binsList[i])[] =
If(binPos == 0, 0, countTable[binPos]);
);
colNamesSum = sumdt << Get Column Names (String);
For (i=1, i<= Nitems(colList), i++,
thisName = colNames[colList[i]];
show(thisName);
valueSet = Column(dt, colList[i])[itemRows];
thisValueQ10 = Quantile(0.10, valueSet);
wait(0);
thisValueQ25 = Quantile (0.25, valueSet);
wait(0);
thisValueQ50 = Quantile (0.50, valueSet);
wait(0);
thisValueQ75 = Quantile (0.75, valueSet);
wait(0);
thisValueQ90 = Quantile (0.90, valueSet);
wait(0);
thisValueMean = Mean (valueSet);
wait(0);
thisValueStdDev = Std Dev (valueSet);
wait(0);
show(thisValueStdDev);
thisColQ10 = Column(sumdt, thisName||"_Q10");
thisColQ25 = Column(sumdt, thisName||"_Q25");
thisColQ50 = Column(sumdt, thisName||"_Q50");
thisColQ75 = Column(sumdt, thisName||"_Q75");
thisColQ90 = Column(sumdt, thisName||"_Q90");
thisColMean = Column(sumdt, thisName||"_Mean");
thisColStdDev = Column(sumdt, thisName||"_StdDev");
thisColQ10[] = thisValueQ10;
thisColQ25[] = thisValueQ25;
thisColQ50[] = thisValueQ50;
thisColQ75[] = thisValueQ75;
thisColQ90[] = thisValueQ90;
thisColMean[] = thisValueMean;
thisColStdDev[] = thisValueStdDev;
);
show("Item completed"),
newIt = 0;
show(newIt);
show("Item already exists in summary table!");
New Window("WARNING",
<< modal,
Text Box("Item "||lotId||"-"||itemID||" already in the table"),
Text Box("Skipping this item"),
Button Box("OK")
);
);
);
show("Lot completed");
sumdt << Save();Re:同步模式?在我上次的回复中,我使用了一个小表,不一定会突出显示任何同步问题。 如果有延迟,它将是分位数的计算。 下面的代码计算了1000万个数据点的分位数。 该函数按照您的预期同步运行,即在q的值建立之前,show不会执行。 如果存在同步问题,那么我们会看到q的值显示为零。
vals = J(10000000,1,Random Normal());
q = 0;
q = Quantile(0.5,vals);
show(q);
但是作为一般观察,如果我想确保同步,我会使用Wait(0) - 这通常只与I / O类型问题有关。只有极少数情况下Wait不起作用 - 这是因为执行是在一个单独的线程中运行的。
Re:同步模式?如果您可以提供一些我们可以运行的示例代码来复制问题,那么诊断会容易得多。 没有它我就写了我自己的版本。 它包含您的所有代码,但我提供了表源和目标(sumdt)。 唯一的区别是你有一个符号thisCol [],这意味着你正在使用For Each Row循环。 我不明白它的上下文所以我只使用了For循环:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
colList = dt << Get Column Names(string,numeric);
N = NItems(colList);
sumdt = new table("sumdt",
Add Rows(N),
new column("name", character),
new column("Q10"),
new column("Q25"),
new column("Q50"),
new column("Q75"),
new column("Q90"),
);
selRows = dt << Get Rows Where(:sex=="F");
For (i=1,i<=N,i++,
thisName = colList[i];
Column(sumdt,"name")[i] = thisName;
thisCol = Column(sumdt, "Q10");
valueSet = Column(dt, colList[i])[selRows];
thisValue = Quantile(0.10, valueSet);
thisCol[i] = thisValue;
thisCol = Column(sumdt, "Q25");
thisValue = Quantile (0.25, valueSet);
thisCol[i] = thisValue;
thisCol = Column(sumdt, "Q50");
thisValue = Quantile (0.50, valueSet);
thisCol[i] = thisValue;
thisCol = Column(sumdt, "Q75");
thisValue = Quantile (0.75, valueSet);
thisCol[i] = thisValue;
thisCol = Column(sumdt, "Q90");
thisValue = Quantile (0.90, valueSet);
thisCol[i] = thisValue;
);
此代码工作正常,没有任何同步问题。 您可能希望比较代码并查看不同之处。
Re:同步模式?你可以尝试使用循环。您可以在循环中合并一个步骤,在下一个循环开始之前将值复制到矩阵或关联数组。这可能会让事情跟随你想要的节奏。
最好,
中号