2024-05-18 01:47:18 +00:00
|
|
|
-- 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)
|
2024-05-18 02:00:01 +00:00
|
|
|
let trueValue = 0.2
|
|
|
|
let noiseLevel = 0.15
|
2024-05-18 01:47:18 +00:00
|
|
|
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
|
|
|
|
|