0

I am trying to generate a repeatable random DenseVector for a number of distributions. For the native Breeze distributions (Gaussian, Uniform), this is what I am doing:

implicit val randBasis = RandBasis.withSeed(2022)
// For uniform
val uniformRandoms = Uniform(20, 40).samplesVector(100)
// For Gaussian:
val normalRandoms = Gaussian(20, 2).samplesVector(100)

But, I am struggling to do the same with Triangular distribution, which is using the Apache distribution behind the scenes. The following line generates a different DenseVector everytime:

val traingularRandoms = new TriangularDistribution(10, 15, 20).samplesVector(100)

On the other hand, if I remove the "new" keyword, then I get the following message:

No implicit arguments of type: TriangularDistribution.Impl3[Double, Double, Double, VR_]

How do I generate the same DenseVector using the same seed for Triangular distribution? Thanks for any pointers.

Samik R
  • 1,636
  • 3
  • 15
  • 33

1 Answers1

0

I don't really understand how you're getting that latter error, but the issue is that samplesVector is a method on Breeze distributions, while you have an Apache distribution. You can wrap TriangularDistribution by following what we did for e.g. the F Distribution

dlwh
  • 2,257
  • 11
  • 23
  • Thanks for the comment, however I am not sure I understand. Triangular distribution is already wrapped and available in Breeze: https://github.com/scalanlp/breeze/blob/1e1eca52d4118fa2ca1c16d63f420cd261f71c40/math/src/main/scala/breeze/stats/distributions/TriangularDistribution.scala However, this does not answer how I can have something like `samplesVector`, through which we can generate a repeatable vector. Did you mean something else? – Samik R Nov 25 '22 at 03:40