How do I implement the sigmoid function in Octave?

so given that the sigmoid function is defined as hθ(x) = g(θ^(T)x), how can I implement this funcion in Octave given that g = zeros(size(z)) ?

Topic regression logistic-regression octave

Category Data Science


This will compute the sigmoid of a scalar, vector or matrix.

function g = sigmoid(z)
%   SIGMOID Compute sigmoid function
%   g = SIGMOID(z) computes the sigmoid of z.


% Compute the sigmoid of each value of z (z can be a matrix,
% vector or scalar).

SIGMOID = @(z) 1./(1 + exp(-z));

g = SIGMOID(z);

end

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.