<?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: Finding the inflection point with nlpfdd for best threshold in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957288#M6415</link>
    <description>Yes I do not have the form of the function, just the interval and the y. Do you have any advice for interpolation?</description>
    <pubDate>Mon, 27 Jan 2025 11:46:53 GMT</pubDate>
    <dc:creator>harmonic</dc:creator>
    <dc:date>2025-01-27T11:46:53Z</dc:date>
    <item>
      <title>Finding the inflection point for best threshold</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957277#M6413</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to find the best threshold with a function like that:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="harmonic_0-1737970219118.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104012iA31138C999A7B30C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="harmonic_0-1737970219118.png" alt="harmonic_0-1737970219118.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For now I used the slop function to&amp;nbsp;find the sign differences:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data sorted_QUANTILI_DS;&lt;BR /&gt;set sorted_QUANTILI_DS;&lt;BR /&gt;slope = dif(prob_nozero_cum) / dif(index); /* estimate the slope by using backward difference */&lt;BR /&gt;SlopeChanged = dif(slope); /* indicate when the slope changes */&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Is there a way to use the call nlpfdd based on this article and use the finite-differnece derivatives:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2022/03/02/finite-difference-derivatives-sas.html" target="_blank" rel="noopener"&gt;Finite-difference derivatives in SAS - The DO Loop&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 14:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957277#M6413</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2025-02-10T14:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the inflection point with nlpfdd for best threshold</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957284#M6414</link>
      <description>&lt;P&gt;Yes, assuming that you have a formula for the function. If so, the inflection points are the values of&amp;nbsp;x&amp;nbsp;where the graph changes from concave up to concave down or vice versa. This requires finding a point where the second derivative changes sign, which means you can use the NLPFDD function to obtain numerical second derivatives. You can&amp;nbsp;use the FROOT function in PROC IML to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;find the numerical roots of any 1-D function on a specified interval. In the following, I find the inflection point for the function sin(x) when x is in the interval [pi,2, 3*pi/2]:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* define the function */
start Func(x);
return( sin(x) );
finish;

/* define function that finds the numerical second derivative of 'Func' */
start SecondDeriv(x);
call nlpfdd(fun, deriv, second_deriv, 'Func', x);
return( second_deriv );
finish;

/* find the inflection point for Func on the interval [a,b] */
pi = constant('pi');
a = pi/2;
b = 3*pi/2;
infl_pt = froot("SecondDeriv", a||b );
print infl_pt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your example, the interval would be {0, 50}. You would replace the definition of the FUNC function with your function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have a formula for the function, the problem gets much harder. You have to use some sort of interpolation scheme to approximate the function, then find the inflection point of the interpolant.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 11:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957284#M6414</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-01-27T11:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the inflection point with nlpfdd for best threshold</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957288#M6415</link>
      <description>Yes I do not have the form of the function, just the interval and the y. Do you have any advice for interpolation?</description>
      <pubDate>Mon, 27 Jan 2025 11:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957288#M6415</guid>
      <dc:creator>harmonic</dc:creator>
      <dc:date>2025-01-27T11:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the inflection point with nlpfdd for best threshold</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957306#M6416</link>
      <description>&lt;P&gt;Sure. You say that you want a numerical estimate of the inflection point based only on knowing the function at a finite set of points (x[i], f(x[i])).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what I suggest.&lt;/P&gt;
&lt;P&gt;1. Use a finite-difference formula to approximate the second derivative of the function. I'd suggest using&amp;nbsp;central differences for 2nd derivatives. Formulas are at&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/imlug/imlug_nonlinearoptexpls_sect012.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/imlug/imlug_nonlinearoptexpls_sect012.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You will get a vector (call if D2F) that for each value of x estimates the second derivative at x.&lt;/P&gt;
&lt;P&gt;2. Find the location(s) where the second derivative changes sign.&lt;/P&gt;
&lt;P&gt;3. Let i-1 and i be the indices for which D2F have different sign. Let xL = x[i-1] and xR = x[i], and let yL = D2F[i-1] and yR = D2f[i]. Then you can define&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;m = (yR - yL) / (xR - xL);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;inflectionPt = xL - yL / m;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 15:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/957306#M6416</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-01-27T15:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the inflection point with nlpfdd for best threshold</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/958810#M6456</link>
      <description>&lt;P&gt;In summary, here are two references for how to numerically estimate inflection points:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2025/02/05/inflection-point.html" target="_self"&gt;Find an inflection point for a function when you know a formula (al algorithm) for the function&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2025/02/10/inflection-points-discrete-func.html" target="_self"&gt;Find an inflection point when you know the function only at a finite set of points&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;From what you've said, the second item is relevant to your problem.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 14:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Finding-the-inflection-point-for-best-threshold/m-p/958810#M6456</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-02-10T14:20:16Z</dc:date>
    </item>
  </channel>
</rss>

