Find the 1 dimensional empirical conditional distribution with data

136 Views Asked by At

I need to find the the conditional distribution function empirically of some data $C$, given the value of a particular predictor $y$. I have attempted to use Bayes as follows:

$$ P(C \ |\ y)=\frac{P(y\ |\ C) \ P(C)}{P(y)} $$

Empirically, I have then used the data and Matlabs histogram function to find approximates of $P(y|C)$ and $P(y)$ for a range of $y$ values and then plotted the RHS at the range of $y$. However, this approach doesn't seem rigorous and I can't see how to improve it. The $y$ is discrete taking around 15 potential values.

The other reason why I feel its not rigoruous is that once plotted, the scaling is incorrect as the probability scale is around 1, when $P(C)$ should've taken care to adjust this in theory.

Are there any other simple and rigourous approaches used in theory?

Thanks