<?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: Moving minimum (moving window) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Moving-minimum-moving-window/m-p/275287#M53417</link>
    <description>&lt;P&gt;Would something like this work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");

dt &amp;lt;&amp;lt; New Column("Min height 5 back", 
	Formula(
		Min( // since we want a minumum 
			:height[// the column we want the minimum of
				// a slice of the current row minus 5 (minimum 1 so it's still on the datatable)
				// and current row
				Min( Row() - 5 )::Row() 
			] 
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Jun 2020 20:30:58 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2020-06-24T20:30:58Z</dc:date>
    <item>
      <title>Moving minimum (moving window)</title>
      <link>https://community.jmp.com/t5/Discussions/Moving-minimum-moving-window/m-p/275257#M53402</link>
      <description>&lt;P&gt;Does anyone know how to calculate a moving minimum (or for that matter how to &lt;SPAN&gt;iteratively&lt;/SPAN&gt; select X number of lag rows and do anything to them such as calculate a min, max, range, etc. In this specific example i want to look back over say the last 100 rows and get the minimum value, then move to the next row down and do the same again (over and over).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:15:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Moving-minimum-moving-window/m-p/275257#M53402</guid>
      <dc:creator>RVhydrA</dc:creator>
      <dc:date>2023-06-10T23:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Moving minimum (moving window)</title>
      <link>https://community.jmp.com/t5/Discussions/Moving-minimum-moving-window/m-p/275272#M53410</link>
      <description>&lt;P&gt;The macro below isn't particularly elegant, but will do the job.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For ( i= 100, i &amp;lt;= N Rows ( dt ), i++,

 dt &amp;lt;&amp;lt; Select Rows (Index (i-99, i));
 
 dt &amp;lt;&amp;lt; Subset(
	Selected Rows( 1 ),
	Selected Columns ( 0 ),
	Output Table ("out")
);

Current Data Table ( Data Table ("out"));

x = Col Minimum ( :YourDataColumn );

Close ( Data Table ( "out"), no save);

Column (  "YourMovingWindow" )[i] = x;

)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sub-setting the selected data, the way I've done it, is slow. Perhaps another user has a better idea how to access the selected data and extract the desired product.&lt;/P&gt;&lt;P&gt;I also wonder how a column formula could look like to achieve the results without a macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Kofi&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 18:03:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Moving-minimum-moving-window/m-p/275272#M53410</guid>
      <dc:creator>Monomorphist</dc:creator>
      <dc:date>2020-06-24T18:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Moving minimum (moving window)</title>
      <link>https://community.jmp.com/t5/Discussions/Moving-minimum-moving-window/m-p/275287#M53417</link>
      <description>&lt;P&gt;Would something like this work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");

dt &amp;lt;&amp;lt; New Column("Min height 5 back", 
	Formula(
		Min( // since we want a minumum 
			:height[// the column we want the minimum of
				// a slice of the current row minus 5 (minimum 1 so it's still on the datatable)
				// and current row
				Min( Row() - 5 )::Row() 
			] 
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jun 2020 20:30:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Moving-minimum-moving-window/m-p/275287#M53417</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2020-06-24T20:30:58Z</dc:date>
    </item>
  </channel>
</rss>

