How can I solve log(normalcdf(a-x)-normalcdf(b-x)) with cvx


(Ye Xue) #1

I’m solving an unconstraint cvx problem with object function “log(normalcdf(a-x)-normalcdf(b-x))” but cvx does not contain this function.


(Mark L. Stone) #2

I am presuming that x is your CVX (optimization) varable, and that a and b are constants.

CVX does have an approximation, log_normcdf , which is concave, and therefore can be maximized. But your objective is the log of the integral from b-x to a-x of the standard Normal density, which {superseded by edit below} is neither convex nor concave. Your only hope of using this in CVX might be to formulate a concave series approximation if maximizing, or a convex series approximation if minimizing. I have no reason to believe there is necessarily any such approximation which is adequate for optimization purposes.

Edit: In reply to subsequent post, the integral in question is neither convex nor concave, but its log appears to be concave in x.


(Ye Xue) #3

Thanks,but normalcdf(a-x)-normalcdf(b-x) is actually log concave (convolution of two log concave functions).So -log(normalcdf(a-x)-normalcdf(b-x)) is convex. Can I define this as my own convex function in cvx?


(Mark L. Stone) #4

Sorry. It appears you are correct.

If you find a way of implementing this function in CVX, exactly or to a good approximation, please post it. You can look at cvx/functions and cvx/functions/@cvx to see the current implementation and comments for log_normcdf.

I think you may be able to try a similar approach. The 2nd order Taylor series about x = c is concave due to the (x-c)^2 term having a negative coefficient. So perhaps you can use a piecewise quadratic approximation about different expansion points. I leave the details to you. I don’t know what the accuracy will wind up being, depending on the distance between expansion points.


(Michael C. Grant) #5

I’m certain you cannot represent this function exactly within CVX. To understand why, please see the FAQ that Mark linked to above. I generally do not recommend that users try to implement their own functions, especially if they require approximations. There’s a strong case to be made here that CVX is simply not designed to support problems such as yours.