implemented model constructor with frequencies as weights