'''

Created on Feb 21, 2013
@Author: Rossi Kamal(rossi@khu.ac.kr)under Supervision of Professor Dr Choong Seon Hong(cshong@khu.ac.kr)
Bi_variate_gaussian_distribution_f
=(1/(2*pi)*(SIGMA**(1/2)))*(e**((-1/2)*(x-mu)**t(SIGMA**(-1))*(x-mu) #SIGMA-(big)-variance-covariance matrix


Notable that, x is k*2 matrix, Mean is 1*2 Matrix and SIGMA is 2*2 
'''
from math import *
import numpy.linalg as la
class BiVariateGaussianDistributionProcessorFromXMeanVarianceCorrelationCoefficent:
    def __init__(self, bi_variate_mean_matrix,bi_variate_variance_11_matrix, bi_variate_variance_22_matrix,bi_variate_correlation_12_matrix,bi_variate_x):
            self.bi_variate_mean_matrix=bi_variate_mean_matrix
            self.bi_variate_variance_11_matrix=bi_variate_variance_11_matrix
            self.bi_variate_variance_22_matrix=bi_variate_variance_22_matrix 
            self.bi_variate_correlation_12_matrix=bi_variate_correlation_12_matrix
            self.bi_variate_x=bi_variate_x
    def calculate_bi_variate_gaussian_distribution(self):
        bi_variate_normalizer=1/2*pi*sqrt((self.bi_variate_variance_11_matrix*self.bi_variate_variance_22_matrix)**(1-self.bi_variate_correlation_12_matrix**2))
        bi_variate_distance_between_x_N_mean=exp(-.5*((self.bi_variate_x-self.bi_variate_mean_matrix).transpose())*(la.inv((self.bi_variate_variance_11_matrix*self.bi_variate_variance_22_matrix)**(1-self.bi_variate_correlation_12_matrix**2)))*(self.bi_variate_x-self.bi_variate_mean_matrix))
        return bi_variate_normalizer*bi_variate_distance_between_x_N_mean
        
        
        