# How do we find probability of a binary event occurring in continuous space?

Let us assume we have a magical 1D line of length 1 cm. And we have an unbiased coin. There are points on the line, where the probability of getting head is high. Example: if the coin lands on 0.5 cm, then it has high probability of getting head.

Initial idea: Discretize the line into intervals (say 10). Then we have 10 bins of 0.1 cm. Randomly pick a bin, flip the coin inside that bin and observe the outcome(head/tail.) We count the number of times it was head in each bin. Assume that the number of flips is limited to 30. After 30 flips, we should be able to say $$P(\text{head in }bin_i) = X$$

Is there any better way to handle this? What if we want to discretize the line into 100 bins?

• I don't properly understand the problem. The title says "probability of a binary event" but you don't explicitly say what binary event you want the probability of. "Example: if the coin lands on 0.5 cm, then it has high probability of getting head." This doesn't say clearly what the overall situation is, i.e., how the probability of heads depends on where the coin lands, or how much about this you know and what can be used in the solution. Furthermore, after 30 flips all you can have is an estimate of the probability, but not the probability itself. Commented May 13, 2023 at 20:36
• Chances are you want to estimate how the probability of heads depends on the coin position on the line? Then the only alternative to binning seems to be to make an assumption for a function regarding how the probability depends on the position continuously. This however requires that you know more about how this is expected to play out. Anyway, if you have 30 flips overall, this is a rather low number to say anything precise. With 100 bins you'll have on average less than one flip in each bin, so you can't really estimate probabilities. Even with 10 bins you'll be very imprecise. Commented May 13, 2023 at 20:39
• 0.5 cm was meant as an example. However, I do not know exactly at which x cm, the probability changes from 0.0 to non-zero-positive. I can only know this "after" observing the coin-flip outcome. Since you pointed out, I think I am doing: "estimate how the probability of heads depends on the coin position on the line" Commented May 13, 2023 at 20:55
• you can use logistic regression and its up to you how you transform the original variable using splines etc to model the nonlinearity Commented May 13, 2023 at 21:54

What you have here is a binary regression model with a single continuous input variable on the interval $$[0,1]$$. Your regression model is:

$$Y|X=x \sim \text{Bern}(f(x)) \quad \quad \quad f: [0,1] \rightarrow [0,1],$$

and you are trying to infer the form of the regression function $$f$$. At present this model is highly general and so you will need to think about what type of binary regression model and inference method you want to use. Usually this would mean considering what kind of functional form or smoothness properties the function $$f$$ might be expected to have.

You might decide to narrow down the form of this function to some parametric form and then you would have a parametric binary regression model, or you might simply assume some simple smoothness properties and decide to use a nonparametric binary regression model (see e.g., Diaconis and Freedman 1993). Once you decide on a modelling and inference approach, you should sample from your unit interval at appropriate places (determined by experimental design principles in regression)to get a set of data showing the coin-flip outcomes at the sampled points. You would then take that data and use it to estimate the function $$f$$ using the relevant inference methods for your chosen model.

• Hello! Could you please explain your notations? I understand $f: [0,1] \rightarrow [0,1]$ being the function that maps the position on the line to the Bernouilli parameter; I would understand $X \sim \operatorname{Bern}(f(x))$ if $X$ was the outcome of the coin throw; but I don't understand $Y|X=x \sim \text{Bern}(f(x)) \quad \quad \quad f: [0,1] \rightarrow [0,1]$. What is $Y$? What is $X$? As far as I understand, $x$ is not a random variable, but if $x$ is not a random variable, then what does $x \sim \operatorname{Bern}(f(x))$ mean?
– Stef
Commented May 14, 2023 at 12:37
• @Stef take (Y|X=x) as a whole. This implies that the conditional distribution of Y given an observed value of X=x follows a Bernoulli distribution, which is parametrized as a function of x. Commented May 14, 2023 at 17:07
• @Ghostpunk Thanks!
– Stef
Commented May 14, 2023 at 17:33
• @Stef: In this context, the value $x$ is the place on the line and the random variable $Y$ is the binary outcome. Another way to write the model equation is to say that $\mathbb{P}(Y=1|X=x) = f(x)$.
– Ben
Commented May 14, 2023 at 21:53
• @Ben Thank you for pointing me into a right direction. It is certainly better than my original intention of splitting the line into predefined intervals. Commented May 15, 2023 at 7:22

While this may not be directly answering your question, I can provide an idea using a conditional probability approach, because you want to know the probability of getting head given that you are at some specific position.

As far as I understand, your probability of landing on a bin itself is a random variable, say $$Y$$. I would consider this random variable to follow a multinoulli (or multinomial distribution), with parameters $$p{_i}$$ corresponding to the probability of landing on the bin $$i$$.

Then you do the flipping experiment. Let's represent this experiment by $$X$$. Given that it is an unbiased coin, this follows a uniform distribution with parameter $$p$$=0.5.

Then your probability of getting head given that your coin lands on a particular bin is the conditional probability $$P(X|Y)$$, which equals to $$P(X\bigcap Y)/P(Y)$$. This is the probability that you want to estimate (you do not estimate probabilities though, you estimate parameters). Your question obviously implies that the probability of getting head and being in the bin $$i$$ is not independent, e.g. they have a functional relationship.

You can find the distribution of $$P(Y)$$ by sampling where your coin flips end up at, and then do distribution fitting. If your parameters $$p{_i}$$ turn out to have a well-defined functional relationship, you may generalize this to an increasing number of intervals. However, even at this point you are unable to know the exact probability distribution of $$P(X\bigcap Y)$$, and in practice joint probability distributions are hard to define exactly (precisely the reason we develop regression models). If you have an intuition on how this joint probability distribution changes with respect to the result of experiments, you can choose a suitable distribution and estimate its parameters using your observations.

I want to conclude by saying that generally, probabilistic questions like this actually begin with you defining a probability space following your theorization about a phenomenon. Depending on how the probability space is constructed, you may have different solutions. See: https://www.wikiwand.com/en/Bertrand_paradox_(probability)