Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For a statistical learning problem (classification), I have the data set $\{ (x_i,y_i) \}_{i=1}^n$ with $x_i \in \mathbb{R}^2$ being the input data and $y_i \in \{0,1\}$ the possible classes.

The data is used to compute the log-likelihood for the data, in that equation I have to compute the logistic sigmoid function

$$\sigma(x_i) = \frac{1}{e^{-x_i} + 1}$$

My problem is:

The input data of $x$ is a matrix $X \in \mathbb{R}^{n \times 2}$, now I am confused how I can compute the $\sigma(x_i)$ for a certain value, since one value of the matrix is a tuple, respectively a vector, one row of this matrix.

Any hints on how to approach this problem and compute my $\sigma(x_i)$?

My matrix looks like that:

$$\begin{pmatrix} 1.55545 & -1.00055\\ -1.24155 & 1.58778\\ 1.28068 & -1.0224\\ \vdots & \vdots\\ -1.68505 & 0.290898\\ 1.73686 & 0.793386\\ \end{pmatrix}$$

Hence $x_1 = (1.55545, -1.00055)$, but what is then:

$$\sigma(1.55545, -1.00055) = \frac{1}{e^{????} + 1}$$

The only thing I have found is the Vector exponential which claims that it can be computed by:

$$exp(v) = 1 \cosh(|v|) + \frac{v}{|v|} \sinh(|v|)$$

share|cite|improve this question
Are you sure the matrix structure of your input data is relevant to the problem? Maybe you can just interpret the matrix as an ordinary vector. – Raskolnikov Apr 29 '12 at 10:15
@Raskolnikov I cannot imagine how and dropping one column of the matrix seems not the right way to do it. – Mahoni Apr 30 '12 at 6:26
An $n\times 2$-matrix is just a structured $2n$-vector. What's the problem? – Raskolnikov Apr 30 '12 at 7:39
@Raskolnikov The problem is, for all the input values $x_i$ I will compute with $\sigma(x)$ a vector $p$ which is used in further computations and the dimension has to be $n$, otherwise there will be dimension mismatch. – Mahoni Apr 30 '12 at 8:57
I think you are forgetting an essential step in your logistic model. Which is that you first have to do a linear regression $y_i\sim x_i$ and it is then for the $y_i$ that you compute $\pi_i\sim\sigma(y_i)$. You are just confused about how logistic regression works. Take a look here before proceeding. – Raskolnikov Apr 30 '12 at 9:08
up vote 0 down vote accepted

The $x_i$ of the input data is not the input of the logistic sigmoid function $\sigma(x)$, that $x$ there is only an arbitrary chosen variable name. The actual input of the $\sigma$ function is a scalar function $f$.

In this case here the function is $f(y,x)$, more specific: $$f(1,x) = \phi(x)^T \cdot \beta$$

The $\phi(x)^T$ is just a transposed version of the input vector with additional features. The result is a scalar and therefore $$\frac{1}{e^{f(1,x)} + 1}$$ can be easily computed.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.