[Tex/LaTex] Numbering of each equation within cases with left alignment (both on the page and within the equations)

aligncasesequationsnumbering

I am trying to create a set of equations with curly braces (like cases), each with their own set of numbers derived from the subsection (such as can be done with equations using \numberwithin{equation}{subsection}).
I get a good result where I want one equation number representing all cases of the equation (code below).

\begin{equation}
\mathbb(E)(X) = \int_{-\infty}^{\infty} xdF(x) =
\left\{ \begin{array}{lll}
    \sum_{x \in \mathcal{X}} xf_{X}(x) & =\sum_{x \in \mathcal{X}}x \mathbb{P}(X=x) &\text{ if } X \text{ is discrete}\\
    \\
    \int_{-\infty}^{\infty} xf_{X}(x)dx & &\text{ if } X \text{ is continuous}
\end{array}
\right. 
\end{equation}

What can I do to to have each of the cases numbered individually?

I have tried align and numcases, but each of them has some problem – either the equation or the text aligns right, or the spacing goes awry.

Would appreciate some help for the specific example above, with

  1. Equation aligned to left of page

  2. All text within cells left aligned

  3. Equation numbers on extreme right

  4. An empty cell in the 2nd case and

  5. A blank line in between the two cases.

Best Answer

Another solution (and numbering) with the empheq package (which loads mathtools, which loads amsmath):

\documentclass{article}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters
\usepackage{amsfonts, % for \mathbb and \mathcal macros
            empheq}%

\numberwithin{equation}{subsection}
\setcounter{section}{1}
\setcounter{subsection}{1}

\begin{document}

\begin{subequations}
  \begin{empheq}[left={\mathbb{E}(X)=\displaystyle\int_{-\infty}^{\infty} x\,dF(x)=\empheqlbrace}]{alignat = 2}
    & \sum_{x \in \mathcal{X}} xf_{X}(x) =\sum_{x \in \mathcal{X}} x\mathbb{P}(X=x)
    &\qquad & \text{if $X$ is discrete}, \\
    & \int_{-\infty}^{\infty} xf_{X}(x)\,dx
    & &\text{if $X$ is continuous}. \end{empheq}
    \end{subequations}

\begin{subequations}
  \begin{empheq}[left={\mathbb{E}(X)=\displaystyle∫_{-∞}^{∞} x\,dF(x)=\empheqlbrace}]{flalign}
    & ∑_{x ∈ \mathcal{X}} xf_{X}(x) =∑_{x ∈ \mathcal{X}} x\mathbb{P}(X=x)
    & &\text{if $X$ is discrete},&\hspace{5em} & \\
    & ∫_{-∞}^{∞} xf_{X}(x)\,dx
    && \text{if $X$ is continuous}. \end{empheq}
    \end{subequations}

\end{document}

enter image description here