We consider discretization of continuous variables in an unsupervised context where our objective is to preserve the dependence structure between these variables. We view the discretization as an optimization problem and suggest two algorithmic solutions. We demonstrate the efficiency of our method on several simulated datasets, and illustrate its contribution when inferring Bayesian networks over a discretized real dataset.