1
$\begingroup$

Given a continuous and bounded function $f(t,s)$, $t,s\in[0,1]$, I would like to compute $$\max_{t_2\in [0,1]}\min_{t_1\in [0,1]} |f(t_1,s_1)-f(t_2,s_2)|,$$ for each numeric values of $s_1$ and $s_2$. I tried by combining NMaxValue and NMinValue but the time is prohibitively large.

I read on the Internet that this distance is sometimes referred to as Fréchet or Hausdorff distance. Is there a built-in function in Mathematica that solves this max-min problem (something like NMaxMinValue)? Or which would be the correct algorithm to proceed with?

$\endgroup$
  • $\begingroup$ Is the domain of the variable in the question the same as the real problem you want to solve? $\endgroup$ – Xminer Jun 5 at 9:04
  • $\begingroup$ @Xminer Yes. I have a particular function on $[0,1]\times[0,1]$. I tried to apply NMaxValue of NMinValue. Although after a long time I obtain the correct max-min value, I would like a faster procedure than just combining these two functions. I would expect something as NMaxMinValue. As this distance has a well-known name (Fréchet or Hausdorff), maybe it has been already implemented in Mathematica. $\endgroup$ – user65970 Jun 5 at 9:11
  • $\begingroup$ I searched this community and documents,but no builtin-function for Hausdorff distance here. so,we have to build new one. $\endgroup$ – Xminer Jun 5 at 10:08
  • $\begingroup$ Some undocumented minmax routines exists here $\endgroup$ – Ulrich Neumann Jun 5 at 13:43
  • $\begingroup$ @UlrichNeumann Oh, I've re-invented the degraded wheels... $\endgroup$ – Xminer Jun 5 at 14:42
1
$\begingroup$

(This is example)
There is No Built-in,Documented Function for Hausdorff distance.
Anyway,my code is the following:


f[t_, s_] := Cos[t]*Cos[s];
domain = Range[0, 1, 0.01];
Do[
  Do[
    funvalue[i, j] = f[i, j];
    ,
    {i, domain}];
  , {j, domain}];

AbsoluteTiming[
 data = Outer[
   With[{s1 = #1, s2 = #2},
     Max[
      MapThread[
       With[{x = #},
         Min[
          MapThread[
           (Abs[funvalue[x, s1] - funvalue[#, s2]]) &
           , {domain}]
          ]
         ] &,
       {domain}]
      ]
     ] &,
   domain, domain];

 ArrayPlot[data]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.