Discretize function

Discretize variable on demand