"Roze Rozengard" <iritrozen@gmail.com> wrote in message <hrcb1e$2ue$1@fred.mathworks.com>...
> There are 2 variables:
> X, that has values in range Xr,
> Y, that generally can have values in some other range Yr, but for given X has more chances to be in some narrow (confidence) interval.
> There is also a set of measurments of couples (X, Y). It can include couples with same X and different Ys.
>
> The question is: given additional pair of values (xx, yy), how can I know the probability to receive a this yy for this xx? Is there a Matlab function that can calculate mean and variance for given xx? I can't find it!
> If the function does not exist, it can be implemented like this:
> Collect pairs (X, Y) with xxeps <X< xx+eps, with some small eps
> Calculate probability distribution for those Ys, maybe giving more weight to Ys whose X is closer to xx.
> I just do not want to implement something that already exists.

If you have no a priori knowledge of your variables' joint distribution, there is nothing very sophisticated about your problem. It will of course require an immense number of pair samples to do your task with any reasonable accuracy.
Divide up each range into discrete intervals, the fineness of these depending on the total number of samples available, and count the number of occurrences in each possible pairing. You could put these counts in a matrix. From these counts you can directly calculate the discrete conditional probabilities in the matrix. It is a simple matter of dividing each element by its corresponding columnsum or rowsum.
Assuming there is some reasonable underlying joint density continuity, you could then attempt to fit a smooth function to these discrete conditional probabilities, taking into account of course the interval sizes.
The role played here by matlab would be minimal as compared with the task of gathering the necessary voluminous data and putting counts into a matrix.
Roger Stafford
