30 lines
881 B
Haskell
30 lines
881 B
Haskell
-- app/Main.hs
|
|
import Text.Printf (printf)
|
|
import MUD (updated, getPF, wme)
|
|
import RandomUtils (generateUniformPoints, generateNormalPoints)
|
|
import Data.List (elemIndex)
|
|
import Data.Maybe (fromJust)
|
|
|
|
main :: IO ()
|
|
main = do
|
|
let f = id
|
|
let numData = 100
|
|
let mesh = [-1, -0.995 .. 1]
|
|
lam_lg <- generateUniformPoints 1000 (-1.0, 1.0)
|
|
let trueValue = 0.2
|
|
let noiseLevel = 0.15
|
|
noise <- generateNormalPoints numData 0 noiseLevel
|
|
let d = replicate numData trueValue
|
|
let noisyData = zipWith (+) d noise
|
|
let g x = wme (f x) noisyData noiseLevel
|
|
let q = getPF g lam_lg
|
|
let v = updated g q mesh
|
|
|
|
-- print $ v
|
|
|
|
let maxIndex = fromJust $ elemIndex (maximum v) v
|
|
let mudPoint = mesh !! maxIndex
|
|
|
|
putStrLn $ printf "For (true = %f with sigma = %f and N = %d), the MUD point from mesh is: %f" trueValue noiseLevel numData mudPoint
|
|
|