Added constructor for dist which uses a function instead of a factor