# Density of uniform distribution over two disjoint squares

A probability distribution $$P$$ over $$X \times \{0, 1\}$$. $$P$$ can be defined in term of its marginal distribution over $$X$$ , which we will denote by $$P_X$$ and the conditional labeling distribution, which is defined by the regression function $$\mu(x) = P_{ (x,y) \sim P} [y = 1 \mid x]$$ Consider a 2-dimensional Euclidean domain, that is $$X = \mathbb R^2$$, and the following process of data generation: The marginal distribution over $$X$$ is uniform over two square areas $$[1, 2] \times [1, 2] \cup [3, 4] \times [1.5, 2.5]$$. Points in the first square $$Q_1 = [1, 2] \times [1, 2]$$ are labeled 0 (blue) and points in the second square $$Q_2 = [3, 4] \times [1.5, 2.5]$$ are labeled 1 (red). Describe the density function of $$P_X$$, and the regression function, Bayes predictor and Bayes risk of $$P$$.

In the image, I have defined the Probability density function. I am having trouble in figuring out the pdf of this function in 2 dimensional space.

• We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. – D.W. Oct 9 '20 at 4:04
• Please provide proper attribution for all copied material. See cs.stackexchange.com/help/referencing. – D.W. Oct 9 '20 at 4:04
• @D.W. Thanks for the advice. I'll change the question's language. – brianoconner Oct 9 '20 at 4:05
• Rather than asking us how to solve the exercise for you, what prevents you from solving it on your own? Exercises exist to give you practice (we can't do that for you) and help you diagnose gaps in your knowledge (it is hard for me to tell where those might be based on the limited information you've provided us about your thinking). If there's a gap, can you identify what that gap is, and then ask about that, in a way that isn't tied to any particular exercise? That's what I mean by a conceptual question that will be useful even to someone who isn't looking at the same exercise as you. – D.W. Oct 9 '20 at 7:45
• The title of your question is very general. Can you make it more specific? – Yuval Filmus Oct 9 '20 at 9:16

The density $$p_R$$ of the uniform distribution over a rectangle $$R$$ is given by $$p_R(x) = 0$$ if $$x \notin R$$, and $$p_R(x) = 1/\mathit{area}(R)$$ otherwise. Indeed, up to scaling the distribution must have this form, and the choice $$1/\mathit{area}(R)$$ ensures that $$p_R$$ is a distribution.
In your case, you have a mixture of two such distributions: with probability $$1/2$$ you take a uniform point in $$[1,2] \times [1,2]$$, and with probability $$1/2$$ you take a uniform point in $$[3,4] \times [1.5,2.5]$$. The density function of the mixture is the average of the density functions of the individual distributions.