How to minimize the maximum error?

Good day everyone,
I have this pack of data that are functions of three variables (say, x1, x2 and x3). How do I choose a linear approximating function that minimizes the maximum error between the linear function and the data? I'm getting some approximating functions with an other software that cannot provide this specific detail to choose between them, though, so I'm quite stuck.
On the other hand I've been suggested to use fminimax in MatLab, but it doesn't seem to be usable in this case (to me, and I'm not a "so experienced user" so I may be wrong).
Thank you so much in advance!
Stefano

 Respuesta aceptada

Torsten
Torsten el 7 de Jun. de 2023
Editada: Torsten el 7 de Jun. de 2023
By a "linear approximating function" you mean a function l with
l(x1,x2,x3) = a + b*x1 + c*x2 + d*x3
where a, b, c and d are constants that have to be determined as to minimize the maximum of
abs(a + b*x1 + c*x2 + d*x3 - y)
?
Use "linprog" to solve the optimization problem
min: t
s.c.
a + b*x1 + c*x2 + d*x3 - y <= t
a + b*x1 + c*x2 + d*x3 - y >= -t

1 comentario

Stefano Gilardoni
Stefano Gilardoni el 7 de Jun. de 2023
Thank you for your answer, I'll try the solution you're suggesting! Does it work also when y is a vector? And does this function choose a, b, c and d to minimize the abs(delta)?
I do not know linprog, so I have to ask that... Thank you again.

Iniciar sesión para comentar.

Más respuestas (1)

Torsten
Torsten el 7 de Jun. de 2023
Movida: Torsten el 7 de Jun. de 2023
Example:
rng('default')
n = 100;
x1 = rand(n,1);
x2 = rand(n,1);
x3 = rand(n,1);
y = rand(n,1);
f = [1; 0 ;0; 0; 0];
A = [-ones(n,1),ones(n,1),x1,x2,x3;-ones(n,1),-ones(n,1),-x1,-x2,-x3];
b = [y;-y];
[sol,fval] = linprog(f,A,b)
Optimal solution found.
sol = 5×1
0.4865 0.4639 0.0450 0.0258 0.0348
fval = 0.4865
t = sol(1)
t = 0.4865
a = sol(2)
a = 0.4639
b = sol(3)
b = 0.0450
c = sol(4)
c = 0.0258
d = sol(5)
d = 0.0348

3 comentarios

Stefano Gilardoni
Stefano Gilardoni el 8 de Jun. de 2023
Perfect, thank you again. I'll test it out this morning!
Stefano Gilardoni
Stefano Gilardoni el 8 de Jun. de 2023
I'm still trying to use linprog on the problem I have. Once that I will have understood linprog and solved the problem with this function, then I will accept your answer! Thank you again.
Instead of
x1 = rand(n,1);
x2 = rand(n,1);
x3 = rand(n,1);
y = rand(n,1);
you just have to supply your data as column vectors.

Iniciar sesión para comentar.

Productos

Versión

R2023a

Preguntada:

el 7 de Jun. de 2023

Comentada:

el 8 de Jun. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by