# Prove that if $\eta = \log(\frac{\phi}{1-\phi})$ then $\phi = \frac{1}{1+e^{-\eta}}$

In the pdf supervised learning from Andrew Ng, p. 23, it is said that if $$\eta = \log(\frac{\phi}{1-\phi})$$ then $$\phi = \frac{1}{1+e^{-\eta}}$$ I can we prove it step by step?

I tried backward but got stuck \begin{align} \frac{1}{1+e^{-\eta}}&=\phi\\ \implies 1&=\phi(1+e^{-\eta})\\ &= \phi + \frac{\phi}{e^{\eta}}\\ &= \frac{e^{\eta}\phi + \phi}{e^{\eta}}\\ &= \phi\frac{e^{\eta} + 1}{e^{\eta}} \end{align}

Edit (with help of posted answers) \begin{align} 1&= \phi\frac{e^{\eta} + 1}{e^{\eta}}\\ \implies \frac{1}{\phi} &= \frac{e^{\eta} + 1}{e^{\eta}}\\ \implies \phi &= \frac{e^{\eta}}{e^{\eta} + 1}\\ &= \frac{e^{\eta}}{e^{\eta} + 1}\frac{\frac{1}{e^{\eta}}}{\frac{1}{e^{\eta}}}\\ &=\frac{1}{1+ e^{-\eta}} \end{align}

• This is a great example of how questions on MSE should be asked, with context and effort despite the relatively simple nature of the question. If only all questions here were like this... Oct 13, 2019 at 9:54
• Thanks for the positive feedback @YiFan.
– ecjb
Oct 13, 2019 at 10:13
• I have to say though, that, in this example the context is easy to mention (well known course of andrew Ng available on internet) and the content is also easy (question rather easy: I'm not from a math background). In the past I also posted some not so well received questions: the problem originated from course of a local university (not available on internet) and that formulate the exact formulation of point where I was stuck was itself much more difficult and maybe broader, hence more difficult to write in standard way. I'll try to stick to that example in the future
– ecjb
Oct 13, 2019 at 10:19

$$\eta=\log\frac{\phi}{1-\phi}$$

$$\exp\eta=\frac{\phi}{1-\phi}$$

$$(1-\phi)\exp\eta=\phi$$

$$\exp\eta=\phi(1+\exp\eta)$$

$$\phi=\frac{\exp\eta}{1+\exp\eta}$$ $$\phi=\frac{1}{1+\exp(-\eta)}$$

Side note: in statistics, the function $$\phi\to\log\frac{\phi}{1-\phi}$$ is called the logit function, and $$\eta\to\dfrac{1}{1+\exp(-\eta)}$$ is called the logistic function. They are used for logistic regression, for instance.

Alternatively, \begin{align}\eta=\log\frac\phi{1-\phi}&\implies-\eta=-\log\frac\phi{1-\phi}=\log\frac{1-\phi}\phi\\&\implies e^{-\eta}=\frac{1-\phi}\phi=\frac1\phi-1\\&\implies\frac1\phi=1+e^{-\eta}\\&\implies\phi=\frac1{1+e^{-\eta}}.\end{align}

You’re almost there. So $$\phi=\dfrac{e^{\eta}}{e^{\eta}+1}$$ and then just divide top and bottom by $$e^{\eta}$$.