function [mu,R] = find_enclosing_sphere(x,nu)

%input
% x - input points, each row represents one point
% nu - fraction of the points outside the sphere (between
% 0 < nu <= 1 );

%output
% mu - the centroid of the points
% R - radius of the data

[row,col]=size(x);

prob.c = [ nu; ones(row,1)/row; zeros(col,1) ];
prob.blx = [ zeros(row+1,1); -inf(col,1) ];
prob.bux = [ inf(1+row+col,1) ];

prob.qcval = 2*ones(row*col,1);
prob.qcsubk = kron([1:row]',ones(col,1));
prob.qcsubi = repmat([row+1+1:row+1+col]',row,1);
prob.qcsubj = prob.qcsubi;

prob.a = sparse([ -ones(row,1) -eye(row) -2*x]);
prob.blc = -inf(row,1);
prob.buc = -sum(x.*x,2);
[r,res]=mosekopt('echo(0) minimize',prob);
R = sqrt(res.sol.itr.xx(1));
mu = res.sol.itr.xx(1+row+1:1+row+col);

