scalanlp / breeze

Breeze is/was a numerical processing library for Scala.
https://www.scalanlp.org
Apache License 2.0
3.45k stars 692 forks source link

Access to Beta parameters? #763

Closed vreuter closed 4 years ago

vreuter commented 5 years ago

A Uniform instance publicizes its parameters; is there a similar way to access alpha and beta for a Beta?

@ import breeze.stats.distributions.Beta 
import breeze.stats.distributions.Beta

@ val b = new Beta(1, 2) 
b: Beta = breeze.stats.distributions.Beta@2298af09

@ b 
res22: Beta = breeze.stats.distributions.Beta@2298af09

@ b. 
apply               dist                entropy             foreach             logApply            map                 normalizer          sample              unnormalizedLogPdf  withFilter
cdf                 draw                filter              get                 logNormalizer       mean                pdf                 samples             unnormalizedPdf
condition           drawOpt             flatMap             inverseCdf          logPdf              mode                probability         samplesVector       variance
@ import breeze.stats.distributions.Uniform 
import breeze.stats.distributions.Uniform

@ val u = Uniform(0.0, 1.0) 
u: Uniform = Uniform(0.0, 1.0)

@ u. 
apply               copy                entropy             get                 logNormalizer       mean                probability         productPrefix       unnormalizedLogPdf
canEqual            dist                filter              high                logPdf              mode                productArity        sample              unnormalizedPdf
cdf                 draw                flatMap             inverseCdf          low                 normalizer          productElement      samples             variance
condition           drawOpt             foreach             logApply            map                 pdf                 productIterator     samplesVector       withFilter
@ u.low 
res25: Double = 0.0

@ u.high 
res26: Double = 1.0
dlwh commented 4 years ago

(Sorry for being slow; it appears I stopped receiving email notifications. Sorry about that!) Unfortunately it looks like not. it's an easy fix, but I missed that

vreuter commented 4 years ago

Cool, no worries! Could Beta become a case class like Uniform, or do you prefer to just expose the parameters and leave the class otherwise as-is?

vreuter commented 4 years ago

Awesome, thanks @dlwh !