Definition:
class probit
{
public:
// build objects
int nbX;
int nbY;
int nbParams;
int aux_nbOptions;
bool outsideOption;
double rho;
arma::cube Covar;
// member functions
~probit(){};
probit(){};
explicit probit(int nbX_inp, int nbY_inp);
explicit probit(int nbX_inp, int nbY_inp, bool outsideOption_inp);
explicit probit(int nbX_inp, int nbY_inp, double rho_inp, bool outsideOption_inp);
void build(int nbX_inp, int nbY_inp);
void build(int nbX_inp, int nbY_inp, bool outsideOption_inp);
void build(int nbX_inp, int nbY_inp, double rho_inp, bool outsideOption_inp);
void unifCorrelCovMatrices();
void unifCorrelCovMatrices(double rho_inp);
empirical simul();
empirical simul(int* nbDraws, int* seed);
void simul(empirical& obj_out);
void simul(empirical& obj_out, int* nbDraws, int* seed);
private:
void build_prv(int nbX_inp, int nbY_inp, double* rho_inp, bool outsideOption_inp);
};
Example:
arma::mat U(2,3);
U << 1.6 << 3.2 << 1.1 << arma::endr
<< 2.9 << 1.0 << 3.1 << arma::endr;
arma::mat mu(2,3);
mu << 1.0 << 3.0 << 1.0 << arma::endr
<< 2.0 << 1.0 << 3.0 << arma::endr;
//
int nbX = U.n_rows;
int nbY = U.n_cols;
arma::vec n = arma::sum(mu,1);
trame::probit probits;
probits.build(nbX,nbY,true);
//
// correlation matrices
probits.rho = 0.5;
probits.unifCorrelCovMatrices();
//
// empirical object:
int sim_seed = 1777;
int n_draws = 1000;
trame::empirical emp_obj;
probits.simul(emp_obj, &n_draws, &sim_seed);
emp_obj.U = U;
emp_obj.mu = mu;
//
// first compute optimal assignment (mu)
double G_sim_val = emp_obj.G(n);
arma::cout << "G-sim(U): \n" << G_sim_val << arma::endl;
arma::cout << "G-sim -> mu: \n" << emp_obj.mu_sol << arma::endl;
//
// solution to dual problem U*
arma::mat U_star_sim;
double Gstar_sim_val = emp_obj.Gstar(n);
//double Gstar_sim_val = emp_obj.Gstar(n,emp_obj.mu_sol,U_star_sim);
arma::cout << "G*-sim(mu): \n" << Gstar_sim_val << arma::endl;
arma::cout << "\\nabla G-sim*(\\nabla G-sim(U)): \n" << emp_obj.U_sol << arma::endl;
//
// Gbar
arma::mat mu_bar(2,3);
mu_bar.fill(2);
arma::mat U_bar_temp, mu_bar_temp;
double val_Gbar_sim = emp_obj.Gbar(emp_obj.U_sol, mu_bar, n, U_bar_temp, mu_bar_temp);
arma::cout << "Gbar-sim val: \n" << val_Gbar_sim << arma::endl;