Fmincon - error using barrier

Hi all.
I would like get pmf's optimul value in entopy
I started simple test.
I changed pmf to pdf.
but it have some problem.
please, anyone help me?
clc;
clear all;
func = @(k)int_fun(k);
x0 = [0];
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0];
ub = [1];
Q = fmincon(func,x0,A,b,Aeq,beq,lb,ub)
function [ F ] = int_fun(k)
fun = @(x) (-(k*dirac(x-1) + (1-k)*dirac(x+1)).*log(1./(k*dirac(x-1) + (1-k)*dirac(x+1))));
F=integral(fun,-inf,inf);
end

1 Comment

dirac() function gives infinity when its input is 1. It can cause issues in the function fun, making it impossible to integrate
fun = @(x) (-(k*dirac(x-1) + (1-k)*dirac(x+1)).*log(1./(k*dirac(x-1) + (1-k)*dirac(x+1))));
Can you show us the actual problem ad whar are you trying to optimize?

Sign in to comment.

Answers (0)

Asked:

on 21 Apr 2020

Commented:

on 21 Apr 2020

Community Treasure Hunt

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

Start Hunting!