Argmin Inference
Name
UxHwDoubleArgmin, UxHwFloatArgmin — Perform inference with distributional arithmetic.
Synopsis
#include <uxhw.h>
float UxHwFloatArgmin(
float functionOutput,
float * argumentArray,
size_t numberOfArguments,
float * minimizingArgumentInstanceArray
);
double UxHwDoubleArgmin(
double functionOutput,
double * argumentArray,
size_t numberOfArguments,
double * minimizingArgumentInstanceArray
);
Description
The UxHwDoubleArgmin() function performs inference. It
calculates the instances of the distributions in array argumentArray that
produce the minimum value of the input distribution functionOutput. It stores
the minimizing instances in the output array minimizingArgumentInstanceArray
of length numberOfArguments, and returns the minimum value of the input
distribution functionOutput.
Given a function , the of is defined as , that is, the of is the collection of inputs in that result in the minimum value of .
Parameters
-
functionOutput— An input distribution which is a computational result of the distributions in the input arrayargumentArray. This is the distribution whichUxHwDoubleArgmin()andUxHwFloatArgmin()will attempt to minimize. -
argumentArray— An array of input distributions that were used in computingfunctionOutput.UxHwDoubleArgmin()andUxHwFloatArgmin()will attempt to infer the instances of the distributions inargumentArraythat minimizefunctionOutput.. -
numberOfArguments— The size of the input arrayargumentArrayand the output arrayminimizingArgumentInstanceArray. -
minimizingArgumentInstanceArray— The instances of the distributions in the arrayargumentArraythat minimize the value offunctionOutput.
Return values
The minimum value of functionOutput that is obtained when the distributions in
the array argumentArray take on their minimizing values (i.e., values returned
in minimizingArgumentInstanceArray).
Example 1: Finding the minimal circumference of a rectangle with a fixed area
#include <stddef.h>
#include <stdio.h>
#include <uxhw.h>
int
main(void)
{
double area = 25.0;
double baseLength = UxHwDoubleUniformDist(0.0, 5.0);
double sideLength = area / baseLength;
double circumference = 2 * (baseLength + sideLength);
double circumferenceMinimizingBaseLength;
double minimalCircumference;
/*
* Find the instance `circumferenceMinimizingBaseLength`
* of `baseLength` that minimizes `circumference` and
* the corresponding minimal circumference.
*/
minimalCircumference = UxHwDoubleArgmin(
circumference,
&baseLength,
1,
&circumferenceMinimizingBaseLength
);
printf("Circumference minimizing base length: %lf\n",
circumferenceMinimizingBaseLength);
printf("Minimal circumference: %lf\n", minimalCircumference);
return 0;
}
Example 2: Finding the maximum area enclosed by a fixed-length boundary
#include <stddef.h>
#include <stdio.h>
#include <uxhw.h>
int
main(void)
{
double totalBoundaryLength = 20.0;
double baseLength = UxHwDoubleUniformDist(0.0, 10.0);
double sideLength = totalBoundaryLength / 2.0 - baseLength;
double area = baseLength * sideLength;
double areaMaximizingBaseLength;
double maximalArea;
/*
* We want to find the maximizer of `area` (instead of
* minimizer), so we pass the negative value of `area`.
*/
maximalArea = -UxHwDoubleArgmin(
-area,
&baseLength,
1,
&areaMaximizingBaseLength
);
printf("Area maximizing base length: %lf\n", areaMaximizingBaseLength);
printf("Maximal area: %lf\n", maximalArea);
return 0;
}