<?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: Retrieve average amount of time spend above a limit within time series data in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Retrieve-average-amount-of-time-spend-above-a-limit-within-time/m-p/389047#M63913</link>
    <description>Thanks Jim!&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 28 May 2021 13:12:49 GMT</pubDate>
    <dc:creator>RobRobeyns</dc:creator>
    <dc:date>2021-05-28T13:12:49Z</dc:date>
    <item>
      <title>Retrieve average amount of time spend above a limit within time series data</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-average-amount-of-time-spend-above-a-limit-within-time/m-p/389017#M63910</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if there would be an easy way to retrieve the average amount of time (in hours or minutes) that a signal stays above a certain limit within time series data. I have added an example data set in the attachment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added some preliminary SD limits which i calculated based on the mean baseline of the data.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="example.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33109iC43FD8BA7BC226DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="example.png" alt="example.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what would be the avarge amount of time for the signal to return back below 2SD, 3SD or 5SD?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:30:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-average-amount-of-time-spend-above-a-limit-within-time/m-p/389017#M63910</guid>
      <dc:creator>RobRobeyns</dc:creator>
      <dc:date>2023-06-10T23:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve average amount of time spend above a limit within time series data</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-average-amount-of-time-spend-above-a-limit-within-time/m-p/389033#M63911</link>
      <description>&lt;P&gt;It is a pretty simple formula that will calculate the durations.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dur.PNG" style="width: 609px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33111iDE893F3A4AFCEA9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="dur.PNG" alt="dur.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And then I just ran a distribution to see the shape of the data, and to get the mean.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dur2.PNG" style="width: 742px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33112iA4F2C3951236D092/image-size/large?v=v2&amp;amp;px=999" role="button" title="dur2.PNG" alt="dur2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In my example below, I only create one new column that determines the duration time spent over 1 SD.&amp;nbsp; The formula is pretty straight forward so using it to calculate the 2SD etc. should be expandable from the first formula.&lt;/P&gt;
&lt;P&gt;Here is the JSL to do the calculation and display.&amp;nbsp; This can easily be done interactively.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

dt &amp;lt;&amp;lt; New Column( "sd1 Duration",
	Numeric,
	"Continuous",
	Format( "hr:m:s", 13, 0 ),
	Input Format( "hr:m:s", 0 ),
	Formula(
		If( Row() == 1,
			start = 0;
			sdLimit = Col Mean( :Count ) + Col Std Dev( :Count );
		);
		theTime = .;
		If( :Count &amp;lt;= sdLimit &amp;amp; start &amp;gt; 0,
			theTime = :"Date/Time"n - start;
			start = 0;
		);
		If( :Count &amp;gt; sdLimit &amp;amp; start == 0,
			start = :"Date/Time"n
		);
		theTime;
	),
	Set Selected
);

Distribution(
	Continuous Distribution( Column( :sd1 Duration ), Horizontal Layout( 1 ), Vertical( 0 ) ),
	SendToReport(
		Dispatch(
			{"sd1 Duration"},
			"1",
			ScaleBox,
			{Min( -2009.13865683119 ), Max( 143459.453400931 ), Interval( "Hour" ), Inc( 10 ),
			Minor Ticks( 1 )}
		),
		Dispatch(
			{"sd1 Duration"},
			"Distrib Histogram",
			FrameBox,
			{DispatchSeg( Hist Seg( 1 ), Bin Span( 2, 0 ) )}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 May 2021 12:27:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-average-amount-of-time-spend-above-a-limit-within-time/m-p/389033#M63911</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-05-28T12:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve average amount of time spend above a limit within time series data</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-average-amount-of-time-spend-above-a-limit-within-time/m-p/389047#M63913</link>
      <description>Thanks Jim!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 May 2021 13:12:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-average-amount-of-time-spend-above-a-limit-within-time/m-p/389047#M63913</guid>
      <dc:creator>RobRobeyns</dc:creator>
      <dc:date>2021-05-28T13:12:49Z</dc:date>
    </item>
  </channel>
</rss>

