How to calculate $P(A)$ given $P(A|B)$ and with B a continuous variable and $P(B)$ being a normal distribution So I have the following situation. $A$ is a boolean variable and $B$ is a continuous variable. $P(A|B)$ is such that at a given threshold $T$, $P(A|B=T) = 0.5$. There is a cutpoint at $T^-$ where $P(A|B<T^-) = 0$ and a similar cutpoint at $T^+$ where $P(A|B>T^+) = 1$. The probability between $T^-$ and $T$ increases linearly and the same is true between $T$ and $T^+$.
Unfortunately, the sensor that gives me the reading for $B$ isn't perfect and gives me a normal distribution. Given a mean $\mu$ and variance $\sigma^2$ for $P(B)$, how can I calculate $P(A)$?
 A: Mathematically, it sounds like you have the following piecewise linear function for $P(A=1~|~B=t)$:
$$P(A=1~|~B = t) = \left\{\begin{array}{ll} 0 & \text{if}~t < T^-  \\ \frac{t-T^-}{2(T-T^-)} & \text{if}~T^-\leq t\leq T \\\frac{t+(T^+-2T)}{2(T^+-T)} & \text{if}~T<t\leq T^+ \\ 1 & \text{if}~t > T^+\end{array} \right.$$
Further, you have $B\sim \mathcal{N}(\mu, \sigma)$. Equivalently, we could model $B\sim\mathcal{N}(0, 1)$, using thresholds $\bar T^- = \frac{T^--\mu}{\sigma}$, $\bar T = \frac{T-\mu}{\sigma}$, and $\bar T^+ = \frac{T^+-\mu}{\sigma}$.
Computing $P(A=1)$ is an exercise in arithmetic, using the following two identities ($\Phi(\cdot)$ is the normal cdf):
\begin{align*}
\int_a^b \frac{1}{\sqrt{2\pi}}e^{-x^2/2}dx &= \Phi(b)-\Phi(a) \\
\int_a^b \frac{x}{\sqrt{2\pi}}e^{-x^2/2}dx &= \frac{-1}{\sqrt{2\pi}}(e^{-b^2/2}-e^{-a^2/2})
\end{align*}
I've tried not to make any arithmetic errors in working it out:
\begin{align*}
P(A=1) &= \int_{-\infty}^\infty Pr(A=1~|~B=t)\frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt \\
&= \int_{-\infty}^{\bar T^-} Pr(A=1~|~B=t)\frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt + \\
&~~~ \int_{\bar T^-}^{\bar T} Pr(A=1~|~B=t)\frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt + \\
&~~~\int_{\bar T}^{\bar T^+} Pr(A=1~|~B=t)\frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt + \\
&~~~\int_{\bar T^+}^{\infty} Pr(A=1~|~B=t)\frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt \\
&= \int_{\bar T^-}^{\bar T} \frac{t-\bar T^-}{2(\bar T-\bar T^-)}\frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt + \\
&~~~ \int_{\bar T}^{\bar T^+} \frac{t+(\bar T^+-2\bar T)}{2(\bar T^+-\bar T)}\frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt + \\
&~~~\int_{\bar T^+}^{\infty} \frac{1}{\sqrt{2\pi}}e^{-t^2/2} dt \\
&= \frac{e^{-(\bar T^-)^2/2}-e^{-\bar T^2/2}}{2\sqrt{2\pi}(\bar T-\bar T^-)} - \frac{\bar T(\Phi(\bar T)-\Phi(\bar T^-))}{2(\bar T-\bar T^-)} + \\
&~~~\frac{e^{-\bar T^2/2}-e^{-(\bar T^+)^2/2}}{2\sqrt{2\pi}(\bar T^+-\bar T)} + \frac{(\bar T^+-2\bar T)(\Phi(\bar T^+)-\Phi(\bar T))}{2(\bar T^+-\bar T)} + (1-\Phi(\bar T^+))
\end{align*}
