<?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 How to pull discreet numbers from &amp;quot;smoother&amp;quot; fit from scatter chart in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-pull-discreet-numbers-from-quot-smoother-quot-fit-from/m-p/479422#M72360</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am plotting a series of different devices and their signal response responses as a function of time. I wish to pull from each smoother plot the time value once the plot crosses a value, say 3100. The scatter data is too coarse to get the time at which this occurs however if there is a function behind the smoother fit for each device then this information should be available.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know if this is possible and if so how to get this done?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="device vs time.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41740i86066D900CB8D5CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="device vs time.png" alt="device vs time.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 11:23:48 GMT</pubDate>
    <dc:creator>ZeoliteChemist</dc:creator>
    <dc:date>2023-06-11T11:23:48Z</dc:date>
    <item>
      <title>How to pull discreet numbers from "smoother" fit from scatter chart</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-pull-discreet-numbers-from-quot-smoother-quot-fit-from/m-p/479422#M72360</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am plotting a series of different devices and their signal response responses as a function of time. I wish to pull from each smoother plot the time value once the plot crosses a value, say 3100. The scatter data is too coarse to get the time at which this occurs however if there is a function behind the smoother fit for each device then this information should be available.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know if this is possible and if so how to get this done?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="device vs time.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41740i86066D900CB8D5CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="device vs time.png" alt="device vs time.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:23:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-pull-discreet-numbers-from-quot-smoother-quot-fit-from/m-p/479422#M72360</guid>
      <dc:creator>ZeoliteChemist</dc:creator>
      <dc:date>2023-06-11T11:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull discreet numbers from "smoother" fit from scatter chart</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-pull-discreet-numbers-from-quot-smoother-quot-fit-from/m-p/479467#M72366</link>
      <description>&lt;P&gt;JMP does give the functions &lt;CODE class=" language-jsl"&gt;Spline Coef()&lt;/CODE&gt; and &lt;CODE class=" language-jsl"&gt;Spline Eval()&lt;/CODE&gt;.&amp;nbsp; You can use &lt;CODE class=" language-jsl"&gt;Spline Coef()&lt;/CODE&gt; to get the spline parameters, then evaluate that spline at any desired point.&amp;nbsp; You could easily use this with Newtons' method to determine when each spline crosses some value (say 3100).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Just beware that you'll want to normalize the x-data (zero mean, std-dev = 1) before this so that the spline lambda can match what you'd normally expect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example that I just threw together that I believe does what you're asking:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

determine crossover = Function( {table, value, spline lambda, x col, y col, group, precision = 0.1},
	/*
		Determines the x-value for which each spline crosses a threshold
	table:
	value: 			&amp;lt;number&amp;gt;	threshold value to determine at which point each spline crosses
	spline lambda:	&amp;lt;number&amp;gt;	normalized lambda
	x col:			&amp;lt;string&amp;gt;	x-axis for spline (table column name)
	y col:			&amp;lt;string&amp;gt;	y-value for spline (table column name)
	group:			&amp;lt;string&amp;gt;	name of column holding the categorical by-groups of the splines
	precision = 0.1 &amp;lt;number&amp;gt;	Relative precision to search till (relative to value)
	*/
	{Default Local},
	spline number = 64;
	max runs = 10;
	rows = table &amp;lt;&amp;lt; Get Rows Where( Excluded( Row State() ) == 0 );
	groups = Associative Array(  Column( table, group )[rows] ) &amp;lt;&amp;lt; Get Keys;
	curves = [=&amp;gt;];
	For( i = 1, i &amp;lt;= N Items( groups ), i++,
		item = groups[i];
		Eval( Parse( Eval Insert( JSL Quote(
		rows = table &amp;lt;&amp;lt; Get Rows Where( Excluded( Row State() ) == 0 &amp;amp; :Name("^group^") == "^item^" )
		) ) ) );
		curves[item] = [=&amp;gt;];
		curves[item]["rows"] = rows;
		curves[item]["abcissa"] = Column( table, x col )[rows];
		curves[item]["ordinate"] = Column( table, y col )[rows];
		curves[item]["abcissa mean"] = Mean( curves[item]["abcissa"] );
		curves[item]["abcissa stddev"] = Std Dev( curves[item]["abcissa"] );
		If( curves[item]["abcissa stddev"] == 0, curves[item]["abcissa"] = 1 );
		curves[item]["abcissa"] = (curves[item]["abcissa"] - curves[item]["abcissa mean"]) / curves[item]["abcissa stddev"];
		first = Min( curves[item]["abcissa"] );
		last = Max( curves[item]["abcissa"] );
		curves[item]["crossover abcissa"] = .;
		curves[item]["crossover ordinate"] = -1932870987120;
		run = 1;
		coef = Spline Coef( curves[item]["abcissa"], curves[item]["ordinate"], spline lambda );
		While( Abs( value - curves[item]["crossover ordinate"] ) &amp;gt; precision * value &amp;amp; run &amp;lt;= max runs,
			run++;
			points = first :: last :: (last - first) / spline number;
			spline = Spline Eval(
				points,
				coef
			);
			For( j = 1, j &amp;lt;= spline number, j++,
				If( spline[j] &amp;gt; value,
					first = If( j == 1, first, points[j - 1] );
					last = points[j];
					Break();
				,
					If( Abs( value - spline[j] ) &amp;lt; Abs( value - curves[item]["crossover ordinate"] ),
						curves[item]["crossover abcissa"] = points[j] * curves[item]["abcissa stddev"] + curves[item]["abcissa mean"];
						curves[item]["crossover ordinate"] = spline[j];
					)
				)
			);
			If( first == last, Break() );
		);
		first = Min( curves[item]["abcissa"] );
		last = Max( curves[item]["abcissa"] );
		points = first :: last :: (last - first) / spline number;
		curves[item]["spline ordniate"] = Spline Eval(
			points,
			coef
		);
		curves[item]["spline abcissa"] = points * curves[item]["abcissa stddev"] + curves[item]["abcissa mean"];
		curves[item]["abcissa"] = curves[item]["abcissa"] * curves[item]["abcissa stddev"] + curves[item]["abcissa mean"];
	);
	curves
);


// example table 
dt = Open("$SAMPLE_DATA/Nonlinear Examples/Algae Mitscherlich.jmp");

// example lamba to use
lambda = 1;
value = 3.7;


// example plot (with lambda from above)
Current Data Table( dt );
gb = Graph Builder(
	Size( 516, 450 ),
	Show Control Panel( 0 ),
	Variables( X( :Days ), Y( :Algae density ), Overlay( :Treatment ) ),
	Elements( Points( X, Y, Legend( 18 ) ), Smoother( X, Y, Legend( 19 ), Lambda( lambda ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Algae density",
			ScaleBox,
			{Add Ref Line( value, "Solid", "Black", "", 1 )}
		)
	)
);

// Call the function with the various inputs
curves = determine crossover( dt, value, lambda, "Days", "Algae density", "Treatment", 0.001 );


// Put the lines into the graph to double-check the values
gbr = Report( gb );
dt &amp;lt;&amp;lt; Color or Mark by Column( :Treatment );
{y min, y max} = Eval List( {gbr[Axis Box( 2 )] &amp;lt;&amp;lt; Get Min, gbr[Axis Box( 2 )] &amp;lt;&amp;lt; Get Max} );
key = curves &amp;lt;&amp;lt; First;
While( !Is Empty( key ),
	Print( Eval List( {key, curves[key]["crossover abcissa"], curves[key]["crossover ordinate"]} ) );
	color = Color Of( Row State( curves[key]["rows"][1] ) );
	Eval( Eval Expr(
	gbr[Frame Box( 1 )] &amp;lt;&amp;lt; Add Graphics Script(
		Pen Color( Expr( color ) );
		Pen Size( 2 );
		Line( {Expr( curves[key]["crossover abcissa"] ), Expr( y min )}, {Expr( curves[key]["crossover abcissa"] ), Expr( y max )} )
	)
	) );
	key = curves &amp;lt;&amp;lt; Next( key )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErraticAttach_0-1650000730777.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41742i47893698E5DB1594/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErraticAttach_0-1650000730777.png" alt="ErraticAttach_0-1650000730777.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 05:32:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-pull-discreet-numbers-from-quot-smoother-quot-fit-from/m-p/479467#M72366</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-04-15T05:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull discreet numbers from "smoother" fit from scatter chart</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-pull-discreet-numbers-from-quot-smoother-quot-fit-from/m-p/479515#M72374</link>
      <description>&lt;P&gt;The Functional Data Explorer in JMP Pro provides a lot of tools for working with functions, profiles, and curves.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 11:57:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-pull-discreet-numbers-from-quot-smoother-quot-fit-from/m-p/479515#M72374</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-04-15T11:57:34Z</dc:date>
    </item>
  </channel>
</rss>

