cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-335794%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%A6%82%E4%BD%95%E6%B1%82%E9%9A%A8%E6%A9%9F%E9%96%93%E9%9A%94%E6%A8%A3%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-335794%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%9C%89%E4%B8%80%E5%80%8B%E5%AD%98%E5%84%B2%E8%87%A8%E6%99%82%E5%80%BC%E7%9A%84%20csv%20%E6%AA%94%E6%A1%88%E3%80%82%20%E6%88%91%E5%BF%85%E9%A0%88%E6%A0%B9%E6%93%9A%E4%BB%A5%E4%B8%8B%E6%AD%A5%E9%A9%9F%E6%89%BE%E5%88%B0%E6%9F%90%E4%BA%9B%E6%A8%A3%E6%9C%AC%E9%9B%86%E7%9A%84%E7%B5%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%9A%3C%2FP%3E%3CP%3E1.%20%E4%BD%BF%E6%89%80%E6%9C%89%E5%B0%8F%E6%96%BC%2025%20%E7%9A%84%E8%87%A8%E6%99%82%E5%80%BC%E7%AD%89%E6%96%BC%200%20iecolumn%20post_process%3C%2FP%3E%3CP%3E2.%20group_avg%20%E5%88%97%E6%98%AF%E5%BF%BD%E7%95%A5%E5%85%B7%E6%9C%89%E5%A4%A7%E6%96%BC%E6%88%96%E7%AD%89%E6%96%BC%204%20%E5%80%8B%E9%80%A3%E7%BA%8C%E9%9B%B6%E7%9A%84%E8%A1%8C%E8%80%8C%E5%BE%97%E5%87%BA%E7%9A%84%E3%80%82%20%E6%8E%A5%E4%B8%8B%E4%BE%86%E8%A8%88%E7%AE%97%E8%A9%B2%E7%B5%84%E6%A8%A3%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%8C%E5%A6%82%E4%B8%8B%E6%89%80%E7%A4%BA%3C%2FP%3E%3CP%3E3.%20Final_average%E6%AC%84%E4%BD%8D%E6%98%AFgroup_avg%E6%AC%84%E4%BD%8D%E7%94%A2%E7%94%9F%E7%9A%84%E7%B5%90%E6%9E%9C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E6%88%91%E5%80%91%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20jsl%20%E7%B7%A8%E5%AF%AB%E6%AD%A4%E9%81%8E%E7%A8%8B%E7%9A%84%E8%85%B3%E6%9C%AC%EF%BC%9F%3C%2FP%3E%3CP%3E%E9%99%84%E5%8A%A0%20csv%20%E6%96%87%E4%BB%B6%3C%2FP%3E%3CP%3E%E6%9C%80%E7%B5%82%E7%B5%90%E6%9E%9C%E7%82%BA%E6%9C%80%E7%B5%82%E7%B5%90%E6%9E%9C%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E_average%E5%A6%82%E4%B8%8B%E8%A1%A8%E6%89%80%E7%A4%BA%EF%BC%9A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jojmp_0-1605845994525.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jojmp_0-1605845994525.png%22%20style%3D%22width%3A%2097px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jojmp_0-1605845994525.png%22%20style%3D%22width%3A%2097px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F28497i81222E48BFCD84BA%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jojmp_0-1605845994525.png%22%20alt%3D%22jojmp_0-1605845994525.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-335794%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3E%E8%B3%87%E6%96%99%E6%B7%B7%E5%90%88%E8%88%87%E6%B8%85%E7%90%86%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-335925%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E6%B1%82%E9%9A%A8%E6%A9%9F%E9%96%93%E9%9A%94%E6%A8%A3%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-335925%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E7%A8%8B%E5%BC%8F%E7%A2%BC%E7%9A%84%E7%AC%AC%E4%BA%8C%E5%80%8B%E7%89%88%E6%9C%AC%E6%9B%B4%E6%9C%89%E6%95%88%E7%8E%87%E3%80%82%20%E8%80%83%E6%85%AE%E5%88%B0%E6%82%A8%E6%AD%A3%E5%9C%A8%E9%81%8B%E8%A1%8C%E7%9A%84%E6%95%B8%E6%93%9A%E9%87%8F%EF%BC%8C%E6%88%91%E8%AA%8D%E7%82%BA%E9%80%99%E6%9C%83%E6%9C%89%E6%89%80%E5%B9%AB%E5%8A%A9%E3%80%82%E5%AE%83%E6%87%89%E8%A9%B2%E6%8F%90%E4%BE%9B%E7%9B%B8%E5%90%8C%E7%9A%84%E7%B5%90%E6%9E%9C%E3%80%82%E5%A6%82%E6%9E%9C%E6%B2%92%E6%9C%89%EF%BC%8C%E6%82%A8%E5%8F%AF%E4%BB%A5%E5%98%97%E8%A9%A6%E5%BE%9E%E7%A8%8B%E5%BC%8F%E7%A2%BC%E7%9A%84%E7%AC%AC%E4%B8%80%E5%80%8B%E7%89%88%E6%9C%AC%E4%B8%AD%E5%88%AA%E9%99%A4%E6%89%80%E6%9C%89%20Show()%20%E8%AA%9E%E5%8F%A5%EF%BC%8C%E7%9C%8B%E7%9C%8B%E6%98%AF%E5%90%A6%E6%9C%89%E6%95%88%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-335922%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E6%B1%82%E9%9A%A8%E6%A9%9F%E9%96%93%E9%9A%94%E6%A8%A3%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-335922%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E7%AC%AC%E4%B8%80%E5%80%8B%E8%85%B3%E6%9C%AC%E7%B5%A6%E4%BA%86%E6%AD%A3%E7%A2%BA%E7%9A%84%E7%AD%94%E6%A1%88%EF%BC%8C%E4%BD%86%E6%98%AF%E5%85%A9%E5%80%8B%E8%85%B3%E6%9C%AC%E7%9A%84%E8%BC%B8%E5%87%BA%E4%B8%8D%E5%90%8C%EF%BC%8C%E7%82%BA%E4%BB%80%E9%BA%BC%E4%BD%A0%E8%A8%BB%E8%A7%A3%E4%BA%86%E7%A8%8B%E5%BC%8F%E7%A2%BC%E7%9A%84%E6%9F%90%E4%BA%9B%E9%83%A8%E5%88%86%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-335842%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E6%B1%82%E9%9A%A8%E6%A9%9F%E9%96%93%E9%9A%94%E6%A8%A3%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-335842%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%87%B7%E7%96%91%E5%95%8F%E9%A1%8C%E5%9C%A8%E6%96%BC%E6%88%91%E9%8C%AF%E8%AA%A4%E5%9C%B0%E5%9C%A8%E7%A8%8B%E5%BC%8F%E7%A2%BC%E4%B8%AD%E7%95%99%E4%B8%8B%E4%BA%86%E5%B9%BE%E5%80%8B%E3%80%8CShow()%E3%80%8D%E8%AA%9E%E5%8F%A5%EF%BC%8C%E9%80%99%E8%BF%AB%E4%BD%BF%E5%A4%A7%E9%87%8F%E5%AF%AB%E5%85%A5%20JMP%20%E6%97%A5%E8%AA%8C%E3%80%82%3C%2FP%3E%0A%3CP%3E%E4%BB%A5%E4%B8%8B%E6%98%AF%E3%80%8C%E5%BE%8C%E8%99%95%E7%90%86%E3%80%8D%E5%88%97%E8%A6%8F%E7%AF%84%EF%BC%8C%E6%88%91%E8%AA%8D%E7%82%BA%E8%A9%B2%E9%83%A8%E5%88%86%E5%AD%98%E5%9C%A8%E5%B0%8E%E8%87%B4%20JMP%20%E6%8E%9B%E8%B5%B7%E7%9A%84%E5%95%8F%E9%A1%8C%E3%80%82%E5%98%97%E8%A9%A6%E9%81%8B%E8%A1%8C%E5%AE%83%EF%BC%8C%E7%9C%8B%E7%9C%8B%E5%AE%83%E6%98%AF%E5%90%A6%E6%9C%83%E9%81%8B%E8%A1%8C%E8%80%8C%E4%B8%8D%E6%9C%83%E6%8E%9B%E8%B5%B7%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%26lt%3B%26lt%3B%20New%20Column(%20%22group_avg%22%2C%0A%20formula(%0A%20%20value%20%3D%20.%3B%0A%20%20If(%20Row()%20%3D%3D%201%2C%0A%20%20%20flag%20%3D%200%3B%0A%20%20%20zeroCounter%20%3D%200%3B%0A%20%20)%3B%0A%20%20If(%20flag%20%3D%3D%200%20%26amp%3B%20%3Apost%20process%20%26gt%3B%200%2C%0A%20%20%20flag%20%3D%201%3B%0A%20%20%20captureMatrix%20%3D%20%5B%5D%3B%0A%20%20)%3B%0A%20%20If(%20%3Apost%20process%20%3D%3D%200%20%26amp%3B%20flag%20%3D%3D%201%2C%0A%20%20%20zeroCounter%0A%20%20%20%2B%2B)%3B%0A%20%20If(%20flag%20%3D%3D%201%2C%0A%20%20%20captureMatrix%20%3D%20captureMatrix%20%7C%7C%20Matrix(%20%3Apost%20process%20)%3B%0A%20%20%20If(%20zeroCounter%20%3D%3D%204%20%7C%20Row()%20%3D%3D%20N%20Rows(%20dt%20)%2C%0A%20%20%20%20%2F*For(%20i%20%3D%20N%20Cols(%20captureMatrix%20)%2C%20i%20%26gt%3B%3D%201%2C%20i--%2C%0A%20%20%20%20%20If(%20captureMatrix%5Bi%5D%20!%3D%200%2C%0A%20%20%20%20%20%20Break()%2C%0A%20%20%20%20%20%20captureMatrix%5Bi%5D%20%3D%20.%0A%20%20%20%20%20)%0A%20%20%20%20)%3B*%2F%0A%20%20%20%20if(%20Row()%20%3D%3D%20N%20Rows(%20dt%20)%2C%20zerocounter%2B%2B%20)%3B%0A%20%20%20%20value%20%3D%20Mean(%20captureMatrix%5B%201%3A%3A%20ncols(captureMatrix)%20-%20(zeroCounter%20-%201)%5D%20)%3B%0A%20%20%20%20flag%20%3D%200%3B%0A%20%20%20%20zeroCounter%20%3D%200%3B%0A%20%20%20%20captureMatrix%20%3D%20%5B%5D%3B%0A%20%20%20)%3B%0A%20%20)%3B%0A%20%20value%3B%0A%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-335816%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E6%B1%82%E9%9A%A8%E6%A9%9F%E9%96%93%E9%9A%94%E6%A8%A3%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-335816%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%A9%B2%E8%85%B3%E6%9C%AC%E9%81%A9%E7%94%A8%E6%96%BC%E5%B0%8F%E6%96%87%E4%BB%B6%E3%80%82%20%E4%BD%86%E5%A6%82%E6%9E%9C%E6%98%AF%E5%A4%A7%E6%96%87%E4%BB%B6%EF%BC%8C%E5%85%B6%E4%B8%AD%E6%9C%89%2016000%20%E5%80%8B%E9%9B%B6%E8%80%8C%E4%B8%8D%E6%98%AF%204%20%E5%80%8B%20JMP%20%E5%B0%B1%E6%9C%83%E5%81%9C%E6%AD%A2%E5%9B%9E%E6%87%89%E3%80%82%20%E6%9C%89%E4%BB%80%E9%BA%BC%E8%BE%A6%E6%B3%95%E5%8F%AF%E4%BB%A5%E9%98%B2%E6%AD%A2%E9%80%99%E7%A8%AE%E6%83%85%E6%B3%81%E4%B8%A6%E9%81%8B%E8%A1%8C%E8%85%B3%E6%9C%AC%E8%80%8C%E4%B8%8D%E6%9C%83%E6%8E%9B%E8%B5%B7%E5%97%8E%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-335813%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E6%B1%82%E9%9A%A8%E6%A9%9F%E9%96%93%E9%9A%94%E6%A8%A3%E6%9C%AC%E7%9A%84%E5%B9%B3%E5%9D%87%E5%80%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-335813%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BB%A5%E4%B8%8B%E8%85%B3%E6%9C%AC%E5%83%85%E4%BD%BF%E7%94%A8%20TEMP%20%E5%88%97%E5%BB%BA%E7%AB%8B%E8%B3%87%E6%96%99%E8%A1%A8%EF%BC%8C%E7%84%B6%E5%BE%8C%E5%BB%BA%E7%AB%8B%E5%85%B6%E9%A4%98%E5%88%97%E4%B8%A6%E4%BD%BF%E7%94%A8%E5%85%AC%E5%BC%8F%E5%A1%AB%E5%85%85%E5%AE%83%E5%80%91%E3%80%82%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20New%20Table(%20%22temp_temp%22%2C%0A%20Add%20Rows(%2054%20)%2C%0A%20New%20Column(%20%22TEMP%22%2C%0A%20%20Numeric%2C%0A%20%20%22Continuous%22%2C%0A%20%20Format(%20%22Best%22%2C%2012%20)%2C%0A%20%20Set%20Values(%0A%20%20%20%5B23.23019577%2C%2023.44946668%2C%2023.56111955%2C%2023.47601143%2C%2023.36428639%2C%0A%20%20%2023.24016499%2C%2032.42091411%2C%2023%2C%2032.26821731%2C%2032.14990084%2C%2032.42091411%2C%0A%20%20%2032.26821731%2C%2032.14990084%2C%2023.23019577%2C%2023.44946668%2C%2023.56111955%2C%0A%20%20%2023.47601143%2C%2023.36428639%2C%2023.24016499%2C%2032.15353181%2C%2032.16785998%2C%2021%2C%0A%20%20%2032.502366%2C%2032.16261133%2C%2032.15757688%2C%2032.16790474%2C%2023.23019577%2C%0A%20%20%2023.44946668%2C%2023.56111955%2C%2023.47601143%2C%2023.36428639%2C%2023.24016499%2C%0A%20%20%2032.42091411%2C%2010%2C%2032.26821731%2C%2032.14990084%2C%2032.41334166%2C%2032.17456755%2C%0A%20%20%2032.52383338%2C%2032.17310331%2C%2019.28571429%2C%2019.28571429%2C%2019.28571429%2C%0A%20%20%2019.28571429%2C%2034.62948075%2C%2034.28766971%2C%2034.29470736%2C%2034.61532486%2C%0A%20%20%2034.386807%2C%2034.36554216%2C%2034.58410721%2C%2034.28726312%2C%2023.57142857%2C%0A%20%20%2023.57142857%5D%0A%20%20)%0A%20)%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22post%20process%22%2C%20formula(%20If(%20%3ATEMP%20%26lt%3B%3D%2025%2C%200%2C%20%3ATEMP%20)%20)%20)%3B%0Adt%3Apost%20process%20%26lt%3B%26lt%3B%20delete%20formula%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22group_avg%22%2C%0A%20formula(%0A%20%20value%20%3D%20.%3B%0A%20%20If(%20Row()%20%3D%3D%201%2C%0A%20%20%20flag%20%3D%200%3B%0A%20%20%20zeroCounter%20%3D%200%3B%0A%20%20)%3B%0A%20%20If(%20flag%20%3D%3D%200%20%26amp%3B%20%3Apost%20process%20%26gt%3B%200%2C%0A%20%20%20flag%20%3D%201%3B%0A%20%20%20captureMatrix%20%3D%20%5B%5D%3B%0A%20%20%20Show(%20%22start%22%2C%20Row()%2C%20flag%20)%3B%0A%20%20)%3B%0A%20%20If(%20%3Apost%20process%20%3D%3D%200%20%26amp%3B%20flag%20%3D%3D%201%2C%0A%20%20%20zeroCounter%0A%20%20%20%2B%2B)%3B%0A%20%20If(%20flag%20%3D%3D%201%2C%0A%20%20%20captureMatrix%20%3D%20captureMatrix%20%7C%7C%20Matrix(%20%3Apost%20process%20)%3B%0A%20%20%20Show(%20%22cap%22%2C%20Row()%2C%20captureMatrix%20)%3B%0A%20%20%20If(%20zeroCounter%20%3D%3D%204%20%7C%20Row()%20%3D%3D%20N%20Rows(%20dt%20)%2C%0A%20%20%20%20For(%20i%20%3D%20N%20Cols(%20captureMatrix%20)%2C%20i%20%26gt%3B%3D%201%2C%20i--%2C%0A%20%20%20%20%20If(%20captureMatrix%5Bi%5D%20!%3D%200%2C%0A%20%20%20%20%20%20Break()%2C%0A%20%20%20%20%20%20captureMatrix%5Bi%5D%20%3D%20.%0A%20%20%20%20%20)%0A%20%20%20%20)%3B%0A%20%20%20%20value%20%3D%20Mean(%20captureMatrix%20)%3B%0A%20%20%20%20Show(%20value%20)%3B%0A%20%20%20%20Show(%20Row()%2C%20captureMatrix%2C%20zeroCounter%2C%20Index(%201%2C%20N%20Cols(%20captureMatrix%20)%20-%20(zeroCounter%20-%201)%20)%20)%3B%0A%20%20%20%20flag%20%3D%200%3B%0A%20%20%20%20zeroCounter%20%3D%200%3B%0A%20%20%20%20Show(%20flag%20)%3B%0A%20%20%20%20captureMatrix%20%3D%20%5B%5D%3B%0A%20%20%20)%3B%0A%20%20)%3B%0A%20%20value%3B%0A%20)%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20new%20column(%22final%20Avg%22%2C%0A%20formula(%0A%20%20if(row()%3D%3D1%2C%0A%20%20%20theRows%20%3D%20current%20data%20table()%20%26lt%3B%26lt%3B%20get%20rows%20where(isMissing(%3Agroup_avg)%3D%3D0)%3B%0A%20%20)%3B%0A%20%20If(row()%26lt%3B%3D%20nrows(theRows)%2C%0A%20%20%20value%3D%3Agroup_avg%5BtheRows%5BRow()%5D%5D%2C%0A%20%20%20value%3D.%0A%20%20)%0A%20)%0A)%3B%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
jojmp
Level III

How to find the average of samples at random intervals?

I have a csv file that stores temp values. I have to find the group average for certain set of samples according to below steps:

1. Make all temp values les than 25 equal to zero i.e.column post_process

2. group_avg column is derived by ignoring rows with greater than or equal to 4 consecutive zeroes. Followed by calculating the average of the group of samples as shown below

3. final_average column is the results generated from group_avg column

 

How can we script this process using jsl?

Attaching the csv file

Final result is final_average as in the table below:

jojmp_0-1605845994525.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to find the average of samples at random intervals?

I suspect the issue is that by mistake, I left several "Show()" statements in the code, which forced a lot of writing to the JMP log.

Below is the "post process" column specification, which is the part that I assume is having the issue that is making JMP hang.  Try running it and see if it will run without hanging

dt << New Column( "group_avg",
	formula(
		value = .;
		If( Row() == 1,
			flag = 0;
			zeroCounter = 0;
		);
		If( flag == 0 & :post process > 0,
			flag = 1;
			captureMatrix = [];
		);
		If( :post process == 0 & flag == 1,
			zeroCounter
			++);
		If( flag == 1,
			captureMatrix = captureMatrix || Matrix( :post process );
			If( zeroCounter == 4 | Row() == N Rows( dt ),
				/*For( i = N Cols( captureMatrix ), i >= 1, i--,
					If( captureMatrix[i] != 0,
						Break(),
						captureMatrix[i] = .
					)
				);*/
				if( Row() == N Rows( dt ), zerocounter++ );
				value = Mean( captureMatrix[ 1:: ncols(captureMatrix) - (zeroCounter - 1)] );
				flag = 0;
				zeroCounter = 0;
				captureMatrix = [];
			);
		);
		value;
	)
);
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: How to find the average of samples at random intervals?

Here is a script that creates your data table with just the TEMP column, and then the remaining columns are created and formula are used to populate them.

Names Default To Here( 1 );
dt = New Table( "temp_temp",
	Add Rows( 54 ),
	New Column( "TEMP",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[23.23019577, 23.44946668, 23.56111955, 23.47601143, 23.36428639,
			23.24016499, 32.42091411, 23, 32.26821731, 32.14990084, 32.42091411,
			32.26821731, 32.14990084, 23.23019577, 23.44946668, 23.56111955,
			23.47601143, 23.36428639, 23.24016499, 32.15353181, 32.16785998, 21,
			32.502366, 32.16261133, 32.15757688, 32.16790474, 23.23019577,
			23.44946668, 23.56111955, 23.47601143, 23.36428639, 23.24016499,
			32.42091411, 10, 32.26821731, 32.14990084, 32.41334166, 32.17456755,
			32.52383338, 32.17310331, 19.28571429, 19.28571429, 19.28571429,
			19.28571429, 34.62948075, 34.28766971, 34.29470736, 34.61532486,
			34.386807, 34.36554216, 34.58410721, 34.28726312, 23.57142857,
			23.57142857]
		)
	)
);

dt << New Column( "post process", formula( If( :TEMP <= 25, 0, :TEMP ) ) );
dt:post process << delete formula;

dt << New Column( "group_avg",
	formula(
		value = .;
		If( Row() == 1,
			flag = 0;
			zeroCounter = 0;
		);
		If( flag == 0 & :post process > 0,
			flag = 1;
			captureMatrix = [];
			Show( "start", Row(), flag );
		);
		If( :post process == 0 & flag == 1,
			zeroCounter
			++);
		If( flag == 1,
			captureMatrix = captureMatrix || Matrix( :post process );
			Show( "cap", Row(), captureMatrix );
			If( zeroCounter == 4 | Row() == N Rows( dt ),
				For( i = N Cols( captureMatrix ), i >= 1, i--,
					If( captureMatrix[i] != 0,
						Break(),
						captureMatrix[i] = .
					)
				);
				value = Mean( captureMatrix );
				Show( value );
				Show( Row(), captureMatrix, zeroCounter, Index( 1, N Cols( captureMatrix ) - (zeroCounter - 1) ) );
				flag = 0;
				zeroCounter = 0;
				Show( flag );
				captureMatrix = [];
			);
		);
		value;
	)
);

dt << new column("final Avg",
	formula(
		if(row()==1,
			theRows = current data table() << get rows where(isMissing(:group_avg)==0);
		);
		If(row()<= nrows(theRows),
			value=:group_avg[theRows[Row()]],
			value=.
		)
	)
);

Jim
jojmp
Level III

Re: How to find the average of samples at random intervals?

This scripts works fine for small files. But in case of large files where we have 16000 zeroes instead of 4 JMP stops responding. Is there any way to prevent this and run the script without hang?

txnelson
Super User

Re: How to find the average of samples at random intervals?

I suspect the issue is that by mistake, I left several "Show()" statements in the code, which forced a lot of writing to the JMP log.

Below is the "post process" column specification, which is the part that I assume is having the issue that is making JMP hang.  Try running it and see if it will run without hanging

dt << New Column( "group_avg",
	formula(
		value = .;
		If( Row() == 1,
			flag = 0;
			zeroCounter = 0;
		);
		If( flag == 0 & :post process > 0,
			flag = 1;
			captureMatrix = [];
		);
		If( :post process == 0 & flag == 1,
			zeroCounter
			++);
		If( flag == 1,
			captureMatrix = captureMatrix || Matrix( :post process );
			If( zeroCounter == 4 | Row() == N Rows( dt ),
				/*For( i = N Cols( captureMatrix ), i >= 1, i--,
					If( captureMatrix[i] != 0,
						Break(),
						captureMatrix[i] = .
					)
				);*/
				if( Row() == N Rows( dt ), zerocounter++ );
				value = Mean( captureMatrix[ 1:: ncols(captureMatrix) - (zeroCounter - 1)] );
				flag = 0;
				zeroCounter = 0;
				captureMatrix = [];
			);
		);
		value;
	)
);
Jim
jojmp
Level III

Re: How to find the average of samples at random intervals?

The first script gives the correct answer but the output of both the scripts are not same, why have you commented some part of the code

txnelson
Super User

Re: How to find the average of samples at random intervals?

The second version of the code is more efficient. Given the amount of data you are running I thought it would help.  It should provide the same results.  If it does not, you can try just removing all of the Show() statements from the first version of the code, and if that works.

Jim