79148587

Date: 2024-11-01 15:40:06
Score: 0.5
Natty:
Report link

Based on the suggestion by @dlwh, here's compilable scala 3 code for seeding of breeze DenseMatrix and DenseVector.

import breeze.linalg._
import breeze.stats.distributions._
import org.apache.commons.math3.random.MersenneTwister

object RandomSeedExample {
  def main(args: Array[String]): Unit = {
    val seed = 0
    val randBasis = new RandBasis(new ThreadLocalRandomGenerator(new MersenneTwister(seed))).uniform
    val denseVector = DenseVector.rand(5, randBasis)
    println(denseVector)
    val denseMatrix = DenseMatrix.rand(5, 3, randBasis)
    println(denseMatrix)
  }
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @dlwh
  • Low reputation (0.5):
Posted by: philwalk