measurable

A simple shallowly-embedded DSL for dealing with measures.
Log | Files | Refs | README | LICENSE

commit 3a2c5a94c7d78a717752d223977db21705ed0b80
parent caf2c4a3db97c660c99cf29b088fe171a7c5b88a
Author: Jared Tobin <jared@jtobin.ca>
Date:   Sat, 19 Oct 2013 16:37:40 +1300

Change 'prod' to 'mproduct'.

Diffstat:
Msrc/Measurable.hs | 9+++++----
Mtests/Test.hs | 2+-
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/Measurable.hs b/src/Measurable.hs @@ -101,15 +101,16 @@ convolute mu nu = Measure $ \f -> measure nu $ \x -> f (x + y) -- | Measure subtraction. (does this make sense?) +msubtract :: Num a => Measure a -> Measure a -> Measure a msubtract mu nu = Measure $ \f -> measure nu $ \y -> measure mu $ \x -> f (x - y) -- | Measure multiplication. (does this make sense?) -prod :: Num a => Measure a -> Measure a -> Measure a -prod mu nu = Measure $ \f -> measure nu - $ \y -> measure mu - $ \x -> f (x * y) +mproduct :: Num a => Measure a -> Measure a -> Measure a +mproduct mu nu = Measure $ \f -> measure nu + $ \y -> measure mu + $ \x -> f (x * y) -- | The (sum) identity measure. identityMeasure :: Fractional a => Measure a diff --git a/tests/Test.hs b/tests/Test.hs @@ -54,7 +54,7 @@ main = do let phi = fromDensity $ genLocationNormal 2 xi = fromDensity $ genLocationNormal 3 - zeta = prod phi xi + zeta = mproduct phi xi putStrLn $ "let X ~ N(2, 1), Y ~ N(3, 1). mean of XY (should be 6) " ++ show (mean zeta)