view general/numerical/scalar/safe_exp.m @ 54:9bcf5e133bf0

Added from old stats library.
author samer
date Mon, 23 Feb 2015 16:08:09 +0000
parents cb249ba61e9e
children
line wrap: on
line source
function [y,k]=safe_exp(x,l)
% safe_exp - high dynamic range exponential
%
% safe_exp :: X:[[N,M]] -> [[N,M]], [[1,M]].
%
% returns y and k such that exp(X) = y * exp(k) and
% maximum value in y is 1.

k=max(x,[],1);
y=exp(x-repmat(k,size(x,1),1));