Skip to content

Instantly share code, notes, and snippets.

@dmichael
Created November 1, 2011 03:22
Show Gist options
  • Select an option

  • Save dmichael/1329789 to your computer and use it in GitHub Desktop.

Select an option

Save dmichael/1329789 to your computer and use it in GitHub Desktop.
Sigmoid function
function g = sigmoid(z)
% Compute the sigmoid of z.
% z can be a matrix, vector or scalar.
g = 1.0 ./ (1.0 + exp(-z));
% 1./ (1 + e.^-z); <-- this is equivalent
end
hypothesis = sigmoid(X*theta);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment