scala breeze matrix of random normal values -


i want same result obtained in python with

x=np.random.normal(0, 1, (n_samples, n_features))

i have tried:

import breeze.linalg._  object helloworld {   def main(args: array[string]) {     println("start")      val n_samples = 5     val n_features = 3      val normal01 = breeze.stats.distributions.gaussian(0, 1)     val samples = normal01.sample(n_features*n_features)      val x = densematrix(n_samples, n_features,  samples) // return error        //print(x)   } } 

where error?

replace matrix creation line with:

val x = new densematrix[double](n_samples, n_features, samples.toarray) 

and fix typo on previous line.

for reason constructor doesn't seem in companion object, have use "new" keyword (this bug in breeze, file issue). also, need coerce "samples" regular scala array.


Comments

Popular posts from this blog

mysql - How to unscape text from database in android studio -

php - Admin SDK -- get information about the group -

Making CSS Drop Down Menu 2 Columns -