Convex combination

Introduction
In convex geometry, a convex combination is a linear combination of points (which can be vectors, scalars, or more generally points in an affine space) where all coefficients are non-negative and sum to 1.

Definition - Convex Combination
More formally, given a finite number of points $$x_1, x_2, \dots, x_n$$ in a real vector space, a convex combination of these points is a point of the form
 * $$\lambda_1x_1+\lambda_2x_2+\cdots+\lambda_nx_n$$

where the real numbers $$\lambda_i$$ satisfy $$\lambda_i\ge 0 $$ and $$\lambda_1+\lambda_2+\cdots+\lambda_n=1.$$

Remark - outside of convex hull
In the animation of the tetraeder there are examples of points that In case that on $$\lambda_i$$ is negative, then linear combination
 * fulfill $$\lambda_1+\lambda_2+\cdots+\lambda_n=1$$, but
 * violate the condition $$\lambda_i\ge 0 $$.
 * $$\lambda_1x_1+\lambda_2x_2+\cdots+\lambda_nx_n$$

is a point outside the tetraeder (see animation and consider, when values become negative.

Convex combinations in the plane
If we consider a convex combinations in the plane, then the underlying vector space is the two-dimensional space $$V:=\mathbb{R}^2$$. First, we consider convex combinations of two vectors in $$\mathbb{R}^2$$. Later we transfer that to infinite dimensional vector spaces of functions and visualize convex combination as GIF animation with Open Source Geogebra. By the condition $$\lambda_1 + \lambda_2 = 1$$, scalars are interdependent. For example, if we define $$t \in [0,1]$$, then we can set $$\lambda_1:= (1-t)$$ and $$\lambda_2 := t$$.

Convex combination of two functions


Geogebra: Interaktives Applet - Download: Geogebra-File

Convex Combination as a Mapping
Now we consider the convex combination as a mapping $$K \colon [0,1]\to V$$ into the underlying vector space. Due to the fact that the equation can generally represent 1st order convex combinations of 2 vectors $$v_1, v_2 \in V$$ as follows over the mapping $$K$$:
 * $$ K(t):= (1-t) \cdot v_1 + t \cdot v_2$$

Convex Combination of 2 Points
As a particular example, every convex combination of two points lies on the line segment between the points.

Convex Combination of 2 Functions as Vectors
Let $$[a,b]=[4,7]$$ be an interval and as the first function is defined as a polynomial $$f:[a,b]\to \mathbb{R}$$.

f(x):= \frac{3}{10} \cdot x^2 - 2 $$ As the second function a trigonometric function $$g:[a,b]\to \mathbb{R}$$ was chosen for the convex combination in the vector space of continuous functions.

g(x):= 2 \cdot cos(x) + 1 $$ The animation above illustrates the convex combination $$K(t):= (1-t)\cdot f + t \cdot g$$.

Remark - Vector space of continuous functions
Both functions $$f,g$$ and $$K(t)$$ for all $$t\in [0,1]$$ are elements of the vector space of continuous functions from $$[a,b]$$ to $$\mathbb{R}$$ (i.e. $$f,g,K(t) \in \mathcal{C}([a,b],\mathbb{R})$$ ).

Remark - Deformation
If the first function $$f$$ describes the initial shape and $$g$$ the target shape. A convex combinations of those functions can describe (e.g. in computer graphics) a continuous deformation of an initial shape into a target shape.

Convex combination of more than 2 Points


The figure above, the point $$P$$ is a convex combination of the three points, while $$Q$$ is not. ($$Q$$ is however an affine combination of the three points, as their affine hull is the entire plane.)]]

Convex combination of n points
A set is convex if it contains all convex combinations of its points. The convex hull of a given set of points is identical to the set of all their convex combinations.



\begin{array}{rcl} v & = & \lambda_1 v_1 + \lambda_2 v_2 + \dotsb + \lambda_n v_n \\ & = & \sum_{i=1}^{n} \lambda_i v_i,\\ & \mbox{mit} & 0 \le \lambda_i \le 1,\quad \sum_{i=1}^{n}\lambda_i=1 \,. \end{array} $$

Linear Combinations and Convex Combinations
There exist subsets of a vector space that are not closed under linear combinations but are closed under convex combinations. For example, the interval $$[0,1]$$ is convex but generates the real-number line under linear combinations. Another example is the convex set of probability distributions, as linear combinations preserve neither non-negativity nor affinity (i.e., having total integral one).

Convex combinations of convex combinations
In the animation above you can see a convex combination of 2 vectors in the plane or in a function space. If one uses three points then one can create a 1st order convex combination between every two points. We will now consider higher order convex combinations by constructing e.g. a 2nd order convex combination generated from two 1st order convex combinations. Generally from 2 convex combinations of order $n$ you can create a convex combination of order $n+1$.

Convex hull
The set of all convex combinations of a given set of vectors is called a convex hull (see also p-convex hull).

Video convex combinations in the plane


Geogebra: Interactive applet - Download:' Geogebra-File

Remarks video about convex combinations of order 1, 2 and 3 in Geogebra
In the video you can see convex combinations of the
 * 1st order between $$A_1$$ and $$B_1$$ without auxiliary points,
 * 2nd order between $$A_2$$ and $$B_2$$ with auxiliary point $$S_1$$,
 * 3rd order between $$A_3$$ and $$B_3$$ with auxiliary points $$H_1, H_2$$,

Convex combinations as polynomials of t
Convex combinations can be conceived as polynomials where the coefficients come from a vector space $$(V,+,\cdot,\mathbb{R})$$ (see also Polynomial Algebra). For example, if one chooses $$V:=\mathbb{R}^n$$, one can take a convex combination $$K$$ to be an element of algebra of polynomial $$V[t]$$.

3D convex combination - 1st order
For example, choosing $$n=3$$ and $$V:=\mathbb{R}^3$$, a 1st order convex combination is defined as follows.

A=\begin{pmatrix}1\\2\\4 \end{pmatrix}, \, B=\begin{pmatrix}4\\1\\0 \end{pmatrix}, \, \, K(t):= (1-t) \cdot A + t \cdot B = (B-A) \cdot t + A $$ Thus, a 1st order convex combination yields a polynomial of degree 1. with argument $$t$$. Represent the convex combination in Geogebra 3D with $$t\in[0,1]$$ (see also Representation of a Straight Line by Direction Vector and Location Vector).

3D convex combination - 2nd order
Choosing again $$n=3$$ and $$V:=\mathbb{R}^3$$ with an auxiliary point $$H_1\in V$$, two 1st order convex combinations yield 2nd order convex combinations.

H_1=\begin{pmatrix}2\\2\\2 \end{pmatrix}, \begin{array}{rcl} K_{(1,1)}(t) & := & (H_1-A) \cdot t + A \\ K_{(1,2)}(t) & := & (B-H_1) \cdot t + H_1 \\ K_{2}(t)    & := & ((H_1-A) \cdot t + A)\cdot (1-t) + ((B-H_1) \cdot t + H_1) \cdot t \end{array} $$ Represent $$K_{2}$$ as a polynomial $$K_{2}(t)=P_2 \cdot t^2 +P_1 \cdot t^1 + P_0 \cdot t^0 $$ and calculate for $$n=2$$ ($$n=3,4,. ..$$) the coefficients in $$P_k\in V = \mathbb{R}^3 $$.

Bernstein polynomial - order 1


\begin{array}{rcl} K_{1}(t)    & := & A \cdot (1-t) + B\cdot t \\ & = & A \cdot (1-t)^1 \cdot t^0 + B\cdot (1-t)^0 \cdot t^1 \\ \end{array} $$

Calculation of the polynomial - order 2


\begin{array}{rcl} K_{2}(t)    & := & ((H_1-A) \cdot t + A)\cdot (1-t) + ((B-H_1) \cdot t + H_1) \cdot t \\ & = & (H_1 \cdot t -A \cdot t + A) - (H_1 \cdot t^2 -A \cdot t^2 + A\cdot t) \\ &  & + (B\cdot t^2 -H_1 \cdot t^2 + H_1 \cdot t ) \\ & = & (B - H_1 + A)\cdot t^2 + 2\cdot (H_1 - A) \cdot t + A \end{array} $$

Bernstein polynomial - order 2


\begin{array}{rcl} K_{2}(t) & := & ((H_1-A) \cdot t + A)\cdot (1-t) + ((B-H_1) \cdot t + H_1) \cdot t \\ & = & A \cdot (1-t)^2 + 2 \cdot H_1 \cdot t\cdot (1-t) + B\cdot t^2 \end{array} $$

Bernstein polynomial - order 3


\begin{array}{rcl} K_{3}(t) & := & A \cdot (1-t)^3 + 3\cdot H_1 \cdot (1-t)^2\cdot t + 3\cdot H_2\cdot (1-t)\cdot t^2 + B \cdot t^3 \end{array} $$

Convex combination as a mapping
A convex combination can be used to interpolate points $$A=v_1$$ and $$B=v_n$$. Furthermore, if the auxiliary points $$H_1=v_2$$,....$$H_{n_1}=v_{n-1}$$ are given for a convex combination $$n$$-th order. The convex combinations can be generally thought of as mapping from the interval $$[0,1]$$ to $$\mathbb{R}^n$$ as follows:

\begin{array}{rcl} K_n: & [0,1] & \rightarrow & \mathbb{R}^n \\ & t & \mapsto & \displaystyle \sum_{k=0}^{n} {n\choose k} (1-t)^{n-k}\cdot t^k \cdot v_{k+1} \\ &  &         & =   {n\choose 0} (1-t)^{n} v_1 +   {n\choose 1} (1-t)^{n-1}t v_2 + \ldots +  {n\choose n} t^n v_n \end{array} $$

Interpolations
Convex combinations can also be used to interpolate polynomials. Start first with first order interpolations by interpolating the points with straight lines of the form $$f_k(x):=m_k \cdot x + b_k$$. Here, the points $$\mathbb{D}:=\{(x_0,y_0),\ldots, (x_n,y_n) \}$$ are given data points that are interpolated piecewise using the functions $$f_k(x):=m_k \cdot x + b_k$$. Compute from the convex combinations $$P_k(t)\in \mathbb{R}^2$$ the functional representation $$f_k:[x_{k-1},x_k] \to \mathbb{R}$$ with $$f_k(x):=m_k \cdot x + b_k$$:
 * $$ P_k(t):= (1-t)\cdot \begin{pmatrix} x_{k-1}\\y_{k-1}\end{pmatrix} + t\cdot \begin{pmatrix} x_{k}\\y_{k}\end{pmatrix}$$

Calculation of t as a function of x
Given $$x\in [x_{k-1},x_k] \subset \mathbb{R}$$. We now compute the corresponding $$t\in [0,1]$$ for the convex combination with the preliminary consideration that $$t=0$$ for $$x = x_{k-1}$$ and $$t=1$$ for $$ x= x_k$$. The following figure takes the linear transformation $$T:[x_{k-1},x_k] \to [0,1]$$.
 * $$T(x):=\frac{x-x_{k-1}}{x_{k}-x_{k-1}}$$

Calculation of the function value at x
The convex combination
 * $$ P_k(t):= (1-t)\cdot \begin{pmatrix} x_{k-1}\\y_{k-1}\end{pmatrix} + t\cdot \begin{pmatrix} x_{k}\\y_{k}\end{pmatrix}$$

gives the interpolation point of the graph. However, we only need the y-coordinate of the corresponding interpolation point $$P_k(t)= \begin{pmatrix} (1-t)\cdot x_{k-1} + t\cdot x_k \\(1-t)\cdot y_{k-1} + t\cdot y_k\end{pmatrix}$$. So we use the following term: $$(1-t)\cdot y_{k-1} + t\cdot y_k $$.

Functional representation
Substituting for $$t \in [0,1]$$ gives the linear interpolation function $$f_k:[x_{k-1},x_k] \to \mathbb{R}$$ over:
 * $$f_k(x):= \bigg( 1- \underbrace{ \frac{x-x_{k-1}}{x_{k}-x_{k-1}} }_{=t} \bigg)\cdot y_{k-1} + \bigg( \underbrace{ \frac{x-x_{k-1}}{x_{k}-x_{k-1}} }_{=t} \bigg) \cdot y_k $$.

Learning Tasks

 * Calculate the coefficients $$m_k,b_k \in \mathbb{R}$$ of the function $$f_k:[x_{k-1},x_k] \to \mathbb{R}$$ with $$f_k(x):=m_k \cdot x + b_k$$!
 * Transfer this interpolation to convex combination of order 3 and consider how, depending on the data points, you must choose the two auxiliary points of the interpolation so that the interpolation is differentiable and generates differentiable transitions between the interpolation points in the plot.
 * What geometric properties must auxiliary points between two adjacent interpolation intervals have for differentiability.

Interpolation with convex combination of order 3


Geogebra: Interactive Applet - Download: Geogebra-File



Geogebra: Interactive Applet - Download: Geogebra-File

Develop a mathematical/algebraic description by terms for the following:
 * The green stippled lines are 1st order convex combinations,
 * At the vertices of the open Polygon course, create an angle bisector (constructively, this can be implemented by a rhombus, where two sides and a vertex are defined by two adjacent lines in the polygon course).
 * Create an orthogonal through the connection point of two adjacent lines in the polygon course.
 * Analyze the figure above and determine the next steps for defining the two auxiliary points for a 3rd order convex combination. The procedure is not clear especially at the boundary points of the polygon course. What speaks to your choice of mathematical implementation?

Use altogether methods from linear algebra (e.g. scalar product,... for the vectorial description of the above geometric procedure.

Morphing and the use of convex combinations
In the following section we will consider transformations of images in the context of convex combinations. In Morphing there are different mathematical tools. Here we will only consider aspects in the context of convex combinations.




 * Look at the above GIF animation and first take two different black and white images transform the first image pixel by pixel to the second image by applying a convex combination from gray level values (black=0,...255=white) of a pixel in image 1 to a pixel in image 2 (implementation e.g. in Octave Image Processing v7.3.0 or Octave Image Processing v5.2.0. Note that the convex combinations yields real values of brightness in the gray levels, which must rounded to integer values (e.g. 232.423 to 232 = approximately white). This is necessary due to that the fact that brightness encoding is done with 256 values (Byte).
 * Transfer the procedure to color images only, similarly transferring color values for the primary colors from grayscale values to color values.
 * In the above morphing animation, however, not only static pixel-by-pixel convex combinations are made, but for fixedly defined points, such as eyes, a spatial transformation process also takes place. Consider how, for example, the center of the iris in the eye is spatially shifted from image1 to image2.
 * now connect spatial transformation processes with a color adjustment of the pixels, so that a pixel moves from the location $$(x_1,y_1)$$ in the image matrix to $$(x_2,y_2)$$ and on the way from $$(x_1,y_1)$$ to $$(x_2,y_2)$$ the color changes from yellow to blue.

CAS4Wiki
With the following CAS4Wiki commands you can play around with the definition of curves in $$\mathbb{R}^2$$
 * [https://niebert.github.io/WikiversityDoc/cas4wiki.html?filename=commands4cas_plot3d.json&casdata=%7B%22castype%22%3A%22maxima%22%2C%22commands%22%3A%5B%7B%22cmdtitle%22%3A%22Plot%20curve2d%20-%20Spiral%22%2C%22cmd%22%3A%22curve2d(%5Bt*cos(t)%2Ct*sin(t)%5D%2Ct%5B0%2C16%5D%2Ccolor%5Bgreen%5D%2Clinewidth%5B3%5D)%22%2C%22result4cmd%22%3A%22curve2d%3A%20curve2d(t)%3D%5Bt%20%5C%5Ccdot%20cos(t)%20%20%2Ct%20%5C%5Ccdot%20sin(t)%20%20%5D%20%5C%5Cquad%20%22%7D%2C%7B%22cmdtitle%22%3A%22Convex%20Comb%20-%20K(t)%22%2C%22cmd%22%3A%22curve3d(K(t)%2Ct%5B0%2C1%5D%2Ccolor%5Bblue%5D%2Clinewidth%5B10%5D)%22%2C%22result4cmd%22%3A%22curve3d%3A%20K(t)%3D%5C%5Cleft(%5C%5Cbegin%7Barray%7D%7Bc%7D3%20%5C%5C%5C%5C%204%20%5C%5C%5C%5C%205%5C%5Cend%7Barray%7D%5C%5Cright)%20%5C%5Ccdot%20%20(1-t)%5E3%20%2B%5C%5Cleft(%5C%5Cbegin%7Barray%7D%7Bc%7D5%20%5C%5C%5C%5C%204%20%5C%5C%5C%5C%20-3%5C%5Cend%7Barray%7D%5C%5Cright)%20%5C%5Ccdot%203%20%5C%5Ccdot%20(1-t)%5E2%20%5C%5Ccdot%20t%2B%20%5C%5Cleft(%5C%5Cbegin%7Barray%7D%7Bc%7D-6%20%5C%5C%5C%5C%20-6%20%5C%5C%5C%5C%206%5C%5Cend%7Barray%7D%5C%5Cright)%20%5C%5Ccdot%203%20%5C%5Ccdot%20(1-t)%20%5C%5Ccdot%20t%5E2%20%2B%5C%5Cleft(%5C%5Cbegin%7Barray%7D%7Bc%7D-3%20%5C%5C%5C%5C%20-7%20%5C%5C%5C%5C%200%5C%5Cend%7Barray%7D%5C%5Cright)%20%5C%5Ccdot%20t%5E3%20%20%20%5C%5Cquad%20%22%7D%2C%7B%22cmdtitle%22%3A%22Plot%20curve3d%20-%20cur(t)%22%2C%22cmd%22%3A%22curve3d(cur(t)%2Ccur(t)*2%2Ct%5B0%2C18%5D%2Ccolor%5Bblue%5D%2Clinewidth%5B10%5D)%22%2C%22result4cmd%22%3A%22curve3d%3A%20cur(t)%3D%5Bcos(t)%2Csin(t)%2Ct%5D%20%20%20%5C%5Cquad%20%20curve3d(t)%3D%5Bcos(t)%2Csin(t)%2Ct%5D%20%20%20%5C%5Ccdot%202%20%5C%5Cquad%20%22%7D%5D%2C%22casfunctions%22%3A%5B%7B%22name%22%3A%22g%22%2C%22args%22%3A%22x%2Cy%22%2C%22def%22%3A%22x%5E3%2By%5E2%22%7D%2C%7B%22name%22%3A%22cur%22%2C%22args%22%3A%22t%22%2C%22def%22%3A%22%5Bcos(t)%2Csin(t)%2Ct%5D%22%7D%2C%7B%22name%22%3A%22K%22%2C%22args%22%3A%22t%22%2C%22def%22%3A%22v1*%20(1-t)%5E3%20%2Bv2*3*(1-t)%5E2*t%2B%20v3*3*(1-t)*t%5E2%20%2Bv4*t%5E3%22%7D%5D%2C%22casvariables%22%3A%5B%7B%22name%22%3A%22v1%22%2C%22def%22%3A%22%5B3%2C4%2C5%5D%22%7D%2C%7B%22name%22%3A%22v2%22%2C%22def%22%3A%22%5B5%2C4%2C-3%5D%22%7D%2C%7B%22name%22%3A%22v3%22%2C%22def%22%3A%22%5B-6%2C-6%2C6%5D%22%7D%2C%7B%22name%22%3A%22v4%22%2C%22def%22%3A%22%5B-3%2C-7%2C0%5D%22%7D%5D%7D&title=CAS%20Demo%20X Curves in $$\mathbb{R}^2$$ and $$\mathbb{R}^3$$] 

Other objects

 * Similarly, a convex combination $$X$$ of random variables $$Y_i$$ is a weighted sum (where $$\alpha_i$$ satisfy the same constraints as above) of its component probability distributions, often called a finite mixture distribution, with probability density function:
 * $$f_{X}(x) = \sum_{i=1}^{n} \lambda_i f_{Y_i}(x)$$

Related constructions

 * Linear Combination
 * A conical combination is a linear combination with nonnegative coefficients. When a point $$x$$ is to be used as the reference origin for defining displacement vectors, then $$x$$ is a convex combination of $$n$$ points $$x_1, x_2, \dots, x_n$$ if and only if the zero displacement is a non-trivial conical combination of their $$n$$ respective displacement vectors relative to $$x$$.
 * Weighted means are functionally the same as convex combinations, but they use a different notation. The coefficients (weights) in a weighted mean are not required to sum to 1; instead the weighted linear combination is explicitly divided by the count of the weights.
 * Affine combinations are like convex combinations, but the coefficients are not required to be non-negative. Hence affine combinations are defined in vector spaces over any field.

Page Information
You can display this page as Wiki2Reveal slides

Wiki2Reveal
The Wiki2Reveal slides were created for the Linear algebra' and the Link for the Wiki2Reveal Slides was created with the link generator.


 * This page is designed as a PanDocElectron-SLIDE document type.
 * Source: Wikiversity https://en.wikiversity.org/wiki/Convex%20combination
 * see Wiki2Reveal for the functionality of Wiki2Reveal.

Wikipedia2Wikiversity
This page was based on the following Wikipedia source page:
 * Convex combination https://en.wikipedia.org/wiki/Convex%20combination
 * Date: 1/12/2022 - Source History Wikipedia
 * Wikipedia2Wikiversity-Converter: https://niebert.github.io/Wikipedia2Wikiversity

Konvexkombination