Your question is not clear. I am not sure if what you want is to test for correlation between two data sets of the variables you mentioned or what you want is to calculate the joint probability distribution of those variables.
If it is the former you can use the Pearson product-moment correlation coefficient (PPMCC). This coefficient is obtained by dividing the covariance of the two variables by the product of their standard deviations, the exact formula can be found in any textbook of statics.
If the variables are independent from each other then the PPMCC is 0, in other words there is no correlation between them. If PPMCC is 1, there is an increasing linear correlation between the variables. In other words temperature tends to increase with rainfall.
If PPMCC is -1, the linear correlation between the variables is decreasing (if temperature tends to decrease with rainfall). Similarly, values between 0 and 1
measure how correlated the variables are.
In the R programming environment you can use the function 'cor' to calculate the correlation between two variables, including other types of correlations such as the kendall and spearman techniques.
If what you want is the joint probability distribution of two random variables (assuming they are independent from each other) you can use the function 'expand.grid' in the R environment.
Correlation matrix can be used to understand the magnitude and direction of relationship between the pairs of a set of variables. It is basically a matrix of Pearson correlation coefficients computed for the pairs of variables.
If you want to find out the causality between variables then correlation is not appropriate. In that case depending on the type of data sent and variables, an appropriate model should be specified and estimated.
Correlation matrix can be used to understand the magnitude and direction of relationship between the pairs of a set of variables. It is basically a matrix of Pearson correlation coefficients computed for the pairs of variables.
If you want to find out the causality between variables then correlation is not appropriate. In that case depending on the type of data set and variables, an appropriate model should be specified and estimated.