<?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: limitations of finite-precision arithmetic in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/966029#M6519</link>
    <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;Thank you for your persistence. I will describe my problem as best as I can so that you may detect any errors in my reasoning.&lt;/P&gt;
&lt;P&gt;I am applying a fuzzy similarity measure from Lukasiewicz logic called a "normal Lukasiewicz structure". I have enclosed a partially-completed draft of a paper describing this concept. It is stated in reference [6] in the draft that is attached to this posting.&lt;/P&gt;
&lt;P&gt;I am trying to classify a set of data represented as columns of features that contain measures of a process, in this case, the well-known Wisconsin Breast Cancer data downloaded from the UCI KDD ML archives. Each column has been linearly standardized into [0,1]. I have composed an objective function based on the Lukasiewicz similarity structure to compute the parameters m and p in equation (6) in the draft. Essentially, the Lukasiewicz structure is the generalized mean of the sum of the Minkowski distances between each feature value and the class mean of that feature computed from each subset of the data that are classified into groups by their class values. Equation (6) describes the similarity between feature vector j and class mean vector i. Similarity values lie in the interval [0,1].&lt;/P&gt;
&lt;P&gt;I use differential evolution (DE) to minimize an objective function based on the Lukasiewicz normal structure. The DE algorithm computes pairs m and p for a set of scenarios. I have specified parameter values for the DE algorithm and once all of the scenarios have been run, I choose the set of parameters that produce the maximum Enhanced Matthews Correlation Coefficient. Using this optimal pair of m and p, I score a validation dataset and use the performance metrics to measure the efficacy of the algorithm.&lt;/P&gt;
&lt;P&gt;My difficulties arise when I compute the Lukasiewicz normal structure using parameter values m and p that force the Minkowski differences computed in equation (6) to be very close to 0 or to 1.&lt;/P&gt;
&lt;P&gt;I have attached a SAS program, &lt;EM&gt;compute_similarity.sas&lt;/EM&gt;, that computes the similarity between a feature vector and one or more class mean vectors. It is invoked by the module,&lt;EM&gt; ffss_classify_score_test.sas&lt;/EM&gt; (also attached),which performs preliminary processing before invoking compute_similarity. I also include a PDF file containing the output of ffss_classify_score_test, which contains numerous examples of the case when&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ndx_pred_class&amp;nbsp; = loc( sim_mat[ j, ] = max( sim_mat[ j, ] )) ;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;returns two values, indicating a failure to produce a unique maximum value. This result is not due to a fault in the loc() function, because sim_mat[] contains {0 0} or {1 1} when two values are produced. Rather, the process resulting in the nonuniqueness of the output of the classifier is of interest, to wit, how can I overcome the tendency of values like&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;.9999995284293320000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.0947296688581390000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999949998210000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.0640424310483060000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999999892080000&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;.9999995534842310000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.1050134801112600000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999936572220000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.1031645294170150000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999992193940000&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;which are the contents of the &lt;EM&gt;compute_similarity&lt;/EM&gt; dist[] matrix to be converted to 1’s or 0’s in subsequent computation?&lt;/P&gt;
&lt;P&gt;These are the inputs to&lt;EM&gt; compute_similarity&lt;/EM&gt;:&lt;/P&gt;
&lt;P&gt;x&lt;/P&gt;
&lt;P&gt;.2574131800000000000 &amp;nbsp;1.000000000000000000 &amp;nbsp;.1562455800000000000 &amp;nbsp;1.000000000000000000 &amp;nbsp;.0796267300000000000&lt;/P&gt;
&lt;P&gt;y&lt;/P&gt;
&lt;P&gt;.0616844800000000100 &amp;nbsp;.0947296700000000000 &amp;nbsp;.0587415400000000100 &amp;nbsp;.0640424500000000000 &amp;nbsp;.0259968300000000000&lt;/P&gt;
&lt;P&gt;.1864923200000000000 &amp;nbsp;.1050134800000000000&amp;nbsp; .1709497800000000000 &amp;nbsp;.1031645300000000000 &amp;nbsp;.1276107500000000000&lt;/P&gt;
&lt;P&gt;m&lt;/P&gt;
&lt;P&gt;.0000170200000000000&lt;/P&gt;
&lt;P&gt;p&lt;/P&gt;
&lt;P&gt;9.106516920000000000&lt;/P&gt;
&lt;P&gt;The dist matrix represents the Lukasiewicz similarities between each element of the feature and the respective elements of the two class means to which the feature is being compared.&lt;/P&gt;
&lt;P&gt;dist&lt;/P&gt;
&lt;P&gt;.9999995284293320000 &amp;nbsp;.0947296688581390000 &amp;nbsp;.9999999949998210000 &amp;nbsp;.0640424310483060000 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .9999999999892080000&lt;/P&gt;
&lt;P&gt;.9999995534842310000 &amp;nbsp;.1050134801112600000&amp;nbsp; .9999999936572220000 &amp;nbsp;.1031645294170150000&amp;nbsp; .9999999992193940000&lt;/P&gt;
&lt;P&gt;The rslt vector contains the similarities of the feature vector to each class mean. In this case, there appears to be no similarity, which I surmise is due to the limitations of finite precision arithmetic.&lt;/P&gt;
&lt;P&gt;rslt&lt;/P&gt;
&lt;P&gt;0.000000000000000000 &amp;nbsp;0.000000000000000000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 May 2025 23:49:02 GMT</pubDate>
    <dc:creator>rbettinger</dc:creator>
    <dc:date>2025-05-07T23:49:02Z</dc:date>
    <item>
      <title>limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965701#M6506</link>
      <description>&lt;P&gt;I am trying to use SAS/IML to perform computations with what in some cases are very small numbers, e.g., less than &lt;EM&gt;constant('maceps')&lt;/EM&gt; and am stymied by my inability to make the expression&amp;nbsp;&lt;EM&gt;ndx = loc( vector= max( vector ))&lt;/EM&gt; return only one value instead of &amp;gt; 1 . When, for example, &lt;EM&gt;vector = {8.372E-26 4.63E-103}&lt;/EM&gt;, the variable &lt;EM&gt;ndx&amp;nbsp;&lt;/EM&gt; will contain {0 0} because the two values in&amp;nbsp;&lt;EM&gt;vector&lt;/EM&gt; are smaller than &lt;EM&gt;constant('maceps')&lt;/EM&gt;, which is 2.2e-16.&lt;/P&gt;
&lt;P&gt;I am enclosing the code of an IML module which demonstrates what I want to do, and have included a listing of the inputs and outputs to and from the module for your perusal. For small values of &lt;EM&gt;m&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;p&lt;/EM&gt;, e.g., .01, computing ( &lt;EM&gt;x ## p - y ## p ) ## ( 1/p )&amp;nbsp;&lt;/EM&gt;produces values close to 1, and I see that the results include 0 in the output, or some very small number such that computing &lt;EM&gt;1 + number &amp;gt;&lt;/EM&gt; &lt;EM&gt;1&lt;/EM&gt; results in &lt;EM&gt;False,&amp;nbsp;&lt;/EM&gt;e.g., 0, and not&amp;nbsp;&lt;EM&gt;True&lt;/EM&gt;, e.g., 1 .&lt;/P&gt;
&lt;P&gt;I will be appreciative for any suggestions because I have tried strategies such as scaling the &lt;EM&gt;x&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;y&lt;/EM&gt; values by &lt;EM&gt;constant('maceps'')&lt;/EM&gt; or&amp;nbsp;&lt;EM&gt;constant('small')&lt;/EM&gt; but to no avail. Perturbing &lt;EM&gt;x[ j ]&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;y[ i, j ]&lt;/EM&gt; by adding a uniform random variate in [0,1] # constant('maceps') similarly fails when &lt;EM&gt;1/p&lt;/EM&gt; is large, e.g.,&amp;nbsp;&lt;EM&gt;1/p &amp;gt;&amp;gt; 1&lt;/EM&gt;. For example,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml ;
a =8.372E-26 ;
b=  4.63E-103 ;
p = .01 ;

c = ( a ## p + b ## p ) ## (1/p) ;

print c ;
quit ;

----------
Output:
---------
c
4.985E-19&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TIA,&lt;/P&gt;
&lt;P&gt;Ross&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options nonotes ;

proc iml ;

reset storage=featclus.featclus ;
load module=_all_ ;

start compute_similarity( x, y, m, p ) ;
   /* compute unweighted Lukasiewicz ("normal" (unweighted) Lukasiewicz structure) similarity
    * 
    * purpose: compute similarity between feature vector j, class mean(s) i
    *     
    * parameters: 
    *    x ::= 1 x n_feature vector of features, each column normalized into [0, 1]
    *    
    *    y ::= n_class x n_feature matrix of class means, produced from normalized x features
    */

   if nrow( x ) ^= 1 then run error( 'compute_similarity', 'Feature vector x must be row vector' ) ;
   
   n_classes  = nrow( y ) ; /* # of class means in class mean matrix */
   n_feat     = ncol( x ) ; /* # of features in x vector             */

   dist       = j( n_classes, n_feat, . ) ;
   similarity = j( 1, n_classes, . ) ;
   
   do i = 1 to n_classes ;
      do j = 1 to n_feat ;
         /* compute similarity btwn x, y for each feature element x[ j ], class mean value y[ i, j ] */

         dist[ i, j ] = ( 1 - abs( x[ j ] ## p - y[ i, j ] ## p )) ## ( 1 / p ) ;
      end ; /* j */
   end ; /* i */

   /* compute similarity btwn x, y for each class mean
    * dist[ i , : ]` is mean of row vector for class mean i
    */
   similarity = dist[ , : ]` ## ( 1 / m ) ;
   
   return similarity ;
finish compute_similarity ;

x = { .1 .2, .3 .4, .5 .6, .7 .8 } ;
if any( x = 0 ) then x[ loc( x=0 ) ] = constant( 'maceps' ) ;

y = { .15 .35, .351 .45 } ;
print x y ;

rslt = compute_similarity( x[1,], y, 1,1 ) ;
print rslt ;
rslt = compute_similarity( x[2,], y, .5, .5 ) ;
print rslt ;
rslt = compute_similarity( x[3,], y, .001, .01 ) ;
print rslt ;
rslt = compute_similarity( x[4,], y, .05, .05 ) ;
print rslt ;

rslt = compute_similarity( x[1,], y, 0.000024943605419,   4.148552428951820) ;
print rslt ;

***store module=compute_similarity ;
quit ;&lt;BR /&gt;&lt;BR /&gt;----------&lt;BR /&gt;Output:&lt;BR /&gt;----------&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;ARTICLE id="IDX" aria-label="x_y"&gt;
&lt;TABLE class="table" style="border-spacing: 0;"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;x&lt;/TH&gt;
&lt;TH class="headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;y&lt;/TH&gt;
&lt;TH class="headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data sel-1"&gt;0.1&lt;/TD&gt;
&lt;TD class="r data sel-1"&gt;0.2&lt;/TD&gt;
&lt;TD class="r data sel-1"&gt;0.15&lt;/TD&gt;
&lt;TD class="r data sel-1"&gt;0.35&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;0.3&lt;/TD&gt;
&lt;TD class="r data"&gt;0.4&lt;/TD&gt;
&lt;TD class="r data"&gt;0.351&lt;/TD&gt;
&lt;TD class="r data"&gt;0.45&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;0.5&lt;/TD&gt;
&lt;TD class="r data"&gt;0.6&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;0.7&lt;/TD&gt;
&lt;TD class="r data"&gt;0.8&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;ARTICLE id="IDX1" aria-label="rslt"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="rslt"&gt;&lt;CAPTION aria-label="rslt"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;rslt&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data sel-1"&gt;0.9&lt;/TD&gt;
&lt;TD class="r data sel-1"&gt;0.7495&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;ARTICLE id="IDX2" aria-label="rslt"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="rslt"&gt;&lt;CAPTION aria-label="rslt"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;rslt&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data sel-1"&gt;0.6600432&lt;/TD&gt;
&lt;TD class="r data sel-1"&gt;0.8439022&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;ARTICLE id="IDX3" aria-label="rslt"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="rslt"&gt;&lt;CAPTION aria-label="rslt"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;rslt&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data sel-1"&gt;0&lt;/TD&gt;
&lt;TD class="r data sel-1" style="white-space: nowrap;"&gt;6.03E-139&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;ARTICLE id="IDX4" aria-label="rslt"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="rslt"&gt;&lt;CAPTION aria-label="rslt"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;rslt&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data sel-1" style="white-space: nowrap;"&gt;2.496E-10&lt;/TD&gt;
&lt;TD class="r data sel-1" style="white-space: nowrap;"&gt;3.9649E-6&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;ARTICLE id="IDX5" aria-label="rslt"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="rslt"&gt;&lt;CAPTION aria-label="rslt"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;rslt&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data sel-1" style="white-space: nowrap;"&gt;8.372E-26&lt;/TD&gt;
&lt;TD class="r data sel-1" style="white-space: nowrap;"&gt;4.63E-103&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 May 2025 19:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965701#M6506</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2025-05-04T19:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965708#M6507</link>
      <description>&lt;P&gt;You lost me, but I think you are saying that when you try to compare a series of very small values to a constant that you are getting TRUE as the result because the DIFFERENCE is also very small?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In theory you could just multiply the values by some larger value instead.&amp;nbsp; Perhaps better to use a number that is a power or 2 since the values are stored using binary numbers.&lt;/P&gt;</description>
      <pubDate>Sun, 04 May 2025 21:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965708#M6507</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-05-04T21:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965737#M6509</link>
      <description>Maybe you could use ROUND() to avoid this problem ?&lt;BR /&gt;if any( x = 0 ) then x[ loc( x=0 ) ] = constant( 'maceps' ) ;&lt;BR /&gt;-----&amp;gt;&lt;BR /&gt;if any(   round(x,1E-6)   = 0 ) then x[ loc(    round(x,1E-6)=0   ) ] = constant( 'maceps' ) ;</description>
      <pubDate>Mon, 05 May 2025 10:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965737#M6509</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-05T10:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965741#M6510</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;&amp;nbsp;am stymied by my inability to make the expression&amp;nbsp;ndx = loc( vector= max( vector ))&amp;nbsp;return only one value instead of &amp;gt; 1 . When, for example,&amp;nbsp;vector = {8.372E-26 4.63E-103}, the variable&amp;nbsp;ndx&amp;nbsp;&amp;nbsp;will contain {0 0} because the two values in&amp;nbsp;vector&amp;nbsp;are smaller than&amp;nbsp;constant('maceps'), which is 2.2e-16.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain your first sentence? It cannot be correct because LOC returns either an empty matrix or a set of positive integers. It will never return a zero. Here's what I see, which looks correct:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
vector = {8.372E-26 4.63E-103}; 
ndx = loc( vector= max( vector ));
print ndx;

/*
ndx 
1 
*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I will think about the second half of your question.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 10:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965741#M6510</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-05-05T10:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965748#M6511</link>
      <description>&lt;P&gt;Can you explain what you think is wrong or problematic about the following code that you posted? The computations look okay to me, so I guess I do not understand your concerns:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml ;
a =8.372E-26 ;
b=  4.63E-103 ;
p = .01 ;
c = ( a ## p + b ## p ) ## (1/p) ;
print c ;
quit ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 May 2025 13:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965748#M6511</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-05-05T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965823#M6513</link>
      <description>&lt;P&gt;Thank you for replying. In the interests of using my time well, I am going to avoid trying to solve this problem by rewriting the code that produces the problem. Let's say that I am using Captain Kirk's &lt;EM&gt;Kobayashi&lt;/EM&gt;&lt;EM&gt; Maru&amp;nbsp;&lt;/EM&gt;solution, e.g., he reprogrammed the simulation that was designed to cause him to fail.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 20:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965823#M6513</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2025-05-05T20:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965824#M6514</link>
      <description>&lt;P&gt;Thank you for replying. In the interests of using my time well, I am going to avoid trying to solve this problem by rewriting the code that produces the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 20:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965824#M6514</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2025-05-05T20:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965826#M6515</link>
      <description>&lt;P&gt;Thank you for replying. In the interests of using my time well, I am going to avoid trying to solve this problem by rewriting the code that produces it.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 22:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965826#M6515</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2025-05-05T22:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965871#M6516</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319186"&gt;@rbettinger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for replying. In the interests of using my time well, I am going to avoid trying to solve this problem by rewriting the code that produces it.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have read your posting several times. I do not understand what you think the problem is. Please give ONE example that shows the problem and tell us what you think the correct answer should be.&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 10:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/965871#M6516</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-05-06T10:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: limitations of finite-precision arithmetic</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/966029#M6519</link>
      <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;Thank you for your persistence. I will describe my problem as best as I can so that you may detect any errors in my reasoning.&lt;/P&gt;
&lt;P&gt;I am applying a fuzzy similarity measure from Lukasiewicz logic called a "normal Lukasiewicz structure". I have enclosed a partially-completed draft of a paper describing this concept. It is stated in reference [6] in the draft that is attached to this posting.&lt;/P&gt;
&lt;P&gt;I am trying to classify a set of data represented as columns of features that contain measures of a process, in this case, the well-known Wisconsin Breast Cancer data downloaded from the UCI KDD ML archives. Each column has been linearly standardized into [0,1]. I have composed an objective function based on the Lukasiewicz similarity structure to compute the parameters m and p in equation (6) in the draft. Essentially, the Lukasiewicz structure is the generalized mean of the sum of the Minkowski distances between each feature value and the class mean of that feature computed from each subset of the data that are classified into groups by their class values. Equation (6) describes the similarity between feature vector j and class mean vector i. Similarity values lie in the interval [0,1].&lt;/P&gt;
&lt;P&gt;I use differential evolution (DE) to minimize an objective function based on the Lukasiewicz normal structure. The DE algorithm computes pairs m and p for a set of scenarios. I have specified parameter values for the DE algorithm and once all of the scenarios have been run, I choose the set of parameters that produce the maximum Enhanced Matthews Correlation Coefficient. Using this optimal pair of m and p, I score a validation dataset and use the performance metrics to measure the efficacy of the algorithm.&lt;/P&gt;
&lt;P&gt;My difficulties arise when I compute the Lukasiewicz normal structure using parameter values m and p that force the Minkowski differences computed in equation (6) to be very close to 0 or to 1.&lt;/P&gt;
&lt;P&gt;I have attached a SAS program, &lt;EM&gt;compute_similarity.sas&lt;/EM&gt;, that computes the similarity between a feature vector and one or more class mean vectors. It is invoked by the module,&lt;EM&gt; ffss_classify_score_test.sas&lt;/EM&gt; (also attached),which performs preliminary processing before invoking compute_similarity. I also include a PDF file containing the output of ffss_classify_score_test, which contains numerous examples of the case when&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ndx_pred_class&amp;nbsp; = loc( sim_mat[ j, ] = max( sim_mat[ j, ] )) ;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;returns two values, indicating a failure to produce a unique maximum value. This result is not due to a fault in the loc() function, because sim_mat[] contains {0 0} or {1 1} when two values are produced. Rather, the process resulting in the nonuniqueness of the output of the classifier is of interest, to wit, how can I overcome the tendency of values like&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;.9999995284293320000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.0947296688581390000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999949998210000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.0640424310483060000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999999892080000&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;.9999995534842310000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.1050134801112600000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999936572220000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.1031645294170150000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;.9999999992193940000&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;which are the contents of the &lt;EM&gt;compute_similarity&lt;/EM&gt; dist[] matrix to be converted to 1’s or 0’s in subsequent computation?&lt;/P&gt;
&lt;P&gt;These are the inputs to&lt;EM&gt; compute_similarity&lt;/EM&gt;:&lt;/P&gt;
&lt;P&gt;x&lt;/P&gt;
&lt;P&gt;.2574131800000000000 &amp;nbsp;1.000000000000000000 &amp;nbsp;.1562455800000000000 &amp;nbsp;1.000000000000000000 &amp;nbsp;.0796267300000000000&lt;/P&gt;
&lt;P&gt;y&lt;/P&gt;
&lt;P&gt;.0616844800000000100 &amp;nbsp;.0947296700000000000 &amp;nbsp;.0587415400000000100 &amp;nbsp;.0640424500000000000 &amp;nbsp;.0259968300000000000&lt;/P&gt;
&lt;P&gt;.1864923200000000000 &amp;nbsp;.1050134800000000000&amp;nbsp; .1709497800000000000 &amp;nbsp;.1031645300000000000 &amp;nbsp;.1276107500000000000&lt;/P&gt;
&lt;P&gt;m&lt;/P&gt;
&lt;P&gt;.0000170200000000000&lt;/P&gt;
&lt;P&gt;p&lt;/P&gt;
&lt;P&gt;9.106516920000000000&lt;/P&gt;
&lt;P&gt;The dist matrix represents the Lukasiewicz similarities between each element of the feature and the respective elements of the two class means to which the feature is being compared.&lt;/P&gt;
&lt;P&gt;dist&lt;/P&gt;
&lt;P&gt;.9999995284293320000 &amp;nbsp;.0947296688581390000 &amp;nbsp;.9999999949998210000 &amp;nbsp;.0640424310483060000 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .9999999999892080000&lt;/P&gt;
&lt;P&gt;.9999995534842310000 &amp;nbsp;.1050134801112600000&amp;nbsp; .9999999936572220000 &amp;nbsp;.1031645294170150000&amp;nbsp; .9999999992193940000&lt;/P&gt;
&lt;P&gt;The rslt vector contains the similarities of the feature vector to each class mean. In this case, there appears to be no similarity, which I surmise is due to the limitations of finite precision arithmetic.&lt;/P&gt;
&lt;P&gt;rslt&lt;/P&gt;
&lt;P&gt;0.000000000000000000 &amp;nbsp;0.000000000000000000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 23:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/limitations-of-finite-precision-arithmetic/m-p/966029#M6519</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2025-05-07T23:49:02Z</dc:date>
    </item>
  </channel>
</rss>

