# Convex combination of convex functions

I would like to use the convex combination of two convex functions, but I am not able to formulate the problem because of the no multiplication rule in CVX.
Is there any way to do this?

Here is the problem: I generate a sample set of two Gaussians, and trying to estimate the means and at which time-instance it should belong to which mean. For this I am trying to use the convex combination of two norms. Here is the code:

T = 200;
K=2;

MU1 = [5];
SIGMA1 = [1.5];

MU2 = [0];
SIGMA2 = [.5];

r1 = mvnrnd(MU1,SIGMA1,T/K);
r2 = mvnrnd(MU2,SIGMA2,T/K);

r = [r1; r2];

cvx_begin
variable m1(size(MU1));
variable m2(size(MU2));
variable a1(T,1);
variable a2(T,1);

minimize(sum(norms(r-m1,2,2)'*a1 + norms(r-m2,2,2)'*a2))

subject to
a1 >= zeros(size(a1));
a2 >= zeros(size(a2));
a1 + a2 == ones(size(a1));
cvx_end

As a result I get

??? Error using ==> cvx.mtimes at 153
Disciplined convex programming error:
Cannot perform the operation {convex}*{affine}

Which is correct given that in general {convex}*{affine} function is not convex, but given the conditions that both a1 and a2 is non-negative and they sum up to one, the objective function should be a convex combination of two convex functions, which (I think) is convex.
Am I mistaken somewhere?

You’ll need to be far more specific than this. Post your model perhaps? But products of convex functions are simply not convex in general, so there’s a reason CVX does not allow this.

Thanks, I extended the original question, and sorry if I was not specific enough

Convex combinations are convex only if the mixing variables a1 and a2 are constant. If you allow a1 and a2 to be variables, as you have, then the result is not jointly convex in all variables.