# Probability of a binary event

Let's say we have a parameter $r$ and a binary event $A$ repeatedly happens. The event is binary, so the outcome is either $0$ or $1$. We have collected a lot of data of the form $\{\{r_1,A_1\},\{r_2,A_2\},\cdots,\{r_n,A_n\}\}$ where $r_i\in\mathbb{R}$ and $A_i\in\{0,1\}$.

For example: $\{\{-3,0\},\{-2,1\},\{2,1\},\{2,1\},\{1,0\}\}$

Can we somehow estimate the probability of $A$ being $1$ for a certain $r$. From the example data, it seems when $r=2$ that $A=1$ quite certainly. But the data sample is very very large and I'm totally at a loss at how to estimate this probability. When there are a lot of positive outcomes for certain values of $r$ than that increases the probability of a positive outcome for other values close to $r$.

How can all this be accumulated in order to predict (and how confidently) the probability of a positive outcome once we set an arbitrary $r$?

-
In your example the only time $r = 1$ gives a value of $0$ for $A$. – Unreasonable Sin Oct 6 '11 at 17:25
oops, that's $r=2$, gonna fix that. – vedran Oct 6 '11 at 17:26
@vedran Do you assume $r$ follows a continuous distribution ? – Sasha Oct 6 '11 at 17:50
No, $r$ is a totally random real number. Say, the average grade in high-school. And $A$ would be e.g. "person graduated". Then you collect all people and get their average grade, and whether they eventually graduated. I ask then: Based on that data, with my average grade 4.23, how likely am I to graduate? – vedran Oct 6 '11 at 17:59
@vedran How dig of data-set are you talking ? – Sasha Oct 6 '11 at 18:00

Your data follow a bivariate distribution with one variable being either 0 or 1. So you should filter your data into $r_{i|0}$ and $r_{i|1}$, and either construct histograms for each type, or perform smooth kernel density estimation, assuming that $r$ follows a continuous distribution, or perform parameter fitting for a suitable family of parametric distributions.

Assume that that was done and frame you question in probabilistic language. Knowing what you need might help you find the shortcut to the answer.

I know this is a vague answer, but you've got to precise your question for me to try to do better.

Added: Given that OP intends $r$ to be a continuous variable, it is better to condition on a non-measure zero event. For a continuous variable, the probability that it equals $4.23$ is zero. It is better to condition that $r$ is within some, possibly small interval.

Here is Mathematica simulation based on a fictitious dataset:

To do it on your own, count the number of graduating students from your dataset with their grade in the specified range, and divide over the total number of students with grades in that range.

-
Okay, this certainly helps very much. But something here doesn't make sense. So what if my grades are all, say, $5$, and that's the maximum grade. Then the average would be exactly $5$. You're saying I'm CERTAIN not to graduate? – vedran Oct 6 '11 at 20:47