#pragma once

#include "../generic/Algorithm.h"

class Gaussian2d 
{
	double m_mux;
	double m_muy;
	double m_Cxx;
	double m_Cyy;
	double m_Cxy;

	double m_beta_Cxy;
	double m_factor;
	double m_inv_sqrt_Cxx;

public:

	Gaussian2d();

	Gaussian2d(double mux, double muy, double Cxx, double Cyy, double Cxy);

	static std::unique_ptr<Gaussian2d> construct(double mux, double muy, double Cxx, double Cyy, double Cxy);

	void fix_beta(double beta);

	////////////////////////////////////////////////////////////////////////////////////////
	// Calculate the expectation E[exp(beta * y)1{x > K}] where x,y are correlated g.r.v
	////////////////////////////////////////////////////////////////////////////////////////
	double e_beta_expectation(double beta, double K) const;
	double e_beta_expectation(double K) const;

	static double e_beta_expectation(double beta, double K, double mux, double muy, double Cxx, double Cyy, double Cxy);

};