<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: trying to compute mean based on previous rows' values (need to retrieve historic values) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425441#M67488</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Have you looked into the Lag () function? You can indicate the offset of the rows as shown below.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() &amp;lt; 4,
	.,
	Mean( Lag( :Column 1, 3 ), Lag( :Column 1, 2 ), Lag( :Column 1, 1 ), :Column 1 )
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There might be more elegant ways to do this, but this will work.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
    <pubDate>Mon, 11 Oct 2021 18:59:28 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2021-10-11T18:59:28Z</dc:date>
    <item>
      <title>trying to compute mean based on previous rows' values (need to retrieve historic values)</title>
      <link>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425388#M67479</link>
      <description>&lt;P&gt;Hi - I am trying to figure out how to get jsl to retrieve prior rows' values (values from previous 4 rows) to use in a formula to compute the mean of those rows. For example, let's say my column A has the following values 3,3,2,8,0,2,2.&amp;nbsp; &amp;nbsp; I'd like the formula in column B to compute the mean of column A using values from its prior 4 rows.&amp;nbsp; &amp;nbsp;The mean function is straightforward but having I haven't figured out how to get it to read and use only a subset of past data.&lt;/P&gt;&lt;P&gt;Ex:&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;colA&amp;nbsp; &amp;nbsp;colB&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help on this!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:02:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425388#M67479</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2023-06-09T18:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: trying to compute mean based on previous rows' values (need to retrieve historic values)</title>
      <link>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425441#M67488</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Have you looked into the Lag () function? You can indicate the offset of the rows as shown below.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() &amp;lt; 4,
	.,
	Mean( Lag( :Column 1, 3 ), Lag( :Column 1, 2 ), Lag( :Column 1, 1 ), :Column 1 )
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There might be more elegant ways to do this, but this will work.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 18:59:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425441#M67488</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2021-10-11T18:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: trying to compute mean based on previous rows' values (need to retrieve historic values)</title>
      <link>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425446#M67489</link>
      <description>&lt;P&gt;Nice and simple.&amp;nbsp; It does not seem to be working when I use the new column function.&amp;nbsp; That is, nothing is being populated in my new column (the column holding the mean formula).&amp;nbsp; Here is my script:&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New Column( "hrly turb current",&lt;BR /&gt;numeric,&lt;BR /&gt;continuous,&lt;BR /&gt;Mean( Lag( :pearson_turb_fnu, 4 ), Lag( :pearson_turb_fnu, 3 ),&lt;BR /&gt;Lag( :pearson_turb_fnu, 2 ), Lag(:pearson_turb_fnu, 1) )&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I applying it correctly?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 19:16:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425446#M67489</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2021-10-11T19:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: trying to compute mean based on previous rows' values (need to retrieve historic values)</title>
      <link>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425459#M67490</link>
      <description>&lt;P&gt;I will suggest that you look into the Col Moving Average() function&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
new column("mov avg",formula(
Col Moving Average( :height, 1, 4, 0)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Oct 2021 19:32:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425459#M67490</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-10-11T19:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: trying to compute mean based on previous rows' values (need to retrieve historic values)</title>
      <link>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425496#M67497</link>
      <description>&lt;P&gt;Seems I just needed to add the word "formula" to the equation for it to work properly.&amp;nbsp; Thanks very much TS!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 20:45:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425496#M67497</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2021-10-11T20:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: trying to compute mean based on previous rows' values (need to retrieve historic values)</title>
      <link>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425498#M67498</link>
      <description>&lt;P&gt;Thanks so much Jim.&amp;nbsp; I'll check it out.&amp;nbsp; I also got the Mean (lag) formula to work.&amp;nbsp; &amp;nbsp;: )&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 20:47:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/trying-to-compute-mean-based-on-previous-rows-values-need-to/m-p/425498#M67498</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2021-10-11T20:47:20Z</dc:date>
    </item>
  </channel>
</rss>

