Relation between Variance of Bernoulli and Logistic Regression? In reading this article, I came across the likelihood function for logistic regression which is defined as below (for discussion reasons, please assume discrete case):
$$L(X|P)=\prod_{i=1,y_i=1}^{N} P(\mathbf{x}_i)\prod_{i=1,y_i=0}^{N} (1-P(\mathbf{x}_i))$$
I'm trying to make some sense out of how this equation was derived(it might be in the article, but I may not have understood it).  
Through searching around, I found out that the right hand side very similarly resembles the variance of a bernoulli trial  $p(1-p) $, and since a discrete logistic regression is used for a multiple bernoulli trial case, thought that there might be something related between the two.
In linear regression, one of the metrics used to calculate a good model is by measuring how much of the variance of the dataset is explained by the model.  I thought maximizing the likelihood may be something similar, to maximize the explained variance of the bernoulli trials.  
Is my intuition on the right path, or do I have a very fundamental misunderstanding?
 A: The logistic regression model assumes that you have some entities $i=1,2,...n$ on which you observe a binary outcome $y_i \in \{0,1\}$ (like e.g. does a company default or not) and for which you also measure some characteristics, let's assume the simplified case with only one characteristic $x_i$ (e.g. age of the company). 
So for each of the $n$ companies you know the binary outcome $y_i$ just as well as the value for $x_i$.  It is the assumed that the probability that $y=1$ depends on $x$, so $P(y=1)=\pi(x)$ where $\pi(x)=\frac{1}{1+e^{-\beta_0 - \beta_1 x}}$. 
So if the outcome for the i-th company is $y_i=1$ then this happens with a probability $P(y_i=1)=\pi(x_i)$ if the outcome $y_j=0$ then this happens with a probability $P(y_j=0)=1-\pi(x_j)$. 
If all your observations are independent then the probability to observe $y_1, ... y_n$ is therefore the product of their probabilities (indpendence is assumed).  So for all the companies where you observe a 1, the probability of observing all these as '1' is $\prod_{y_i=1} \pi(x_i)$ for all those were you have zero the probability of all these zeroes is $\prod_{y_i=0} (1-\pi(x_i))$ and the probabilities that you observe all these zeroes and ones is $\prod_{y_i=1} \pi(x_i)\prod_{y_i=0} (1-\pi(x_i))$. 
Note that you can write this as $\prod_i \pi(x_i)^{y_i}(1-\pi(x_i))^{1-y_i}$
