diff options
author | Eduardo Julian | 2018-05-07 01:37:38 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-07 01:37:38 -0400 |
commit | febfa99c2823219c2e76d2c73b1fd8db8f6c9918 (patch) | |
tree | f521419a80b04f465c6c9c5020c2063e2e555895 /stdlib/test | |
parent | 3e2fddc6bfdda56dbe6947c476f85760b0811654 (diff) |
- Implemented Deg functionality in pure Lux.
Diffstat (limited to '')
-rw-r--r-- | stdlib/test/test/lux.lux | 8 | ||||
-rw-r--r-- | stdlib/test/test/lux/math/logic/fuzzy.lux | 29 |
2 files changed, 13 insertions, 24 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index b8861eab6..a089f7cee 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -135,10 +135,10 @@ (|> x' (/ y) (* y) (= x')))) ))))] - ["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> +0 +1 +1000000 %n (n/% +1000) id] - ["Int" r.int i/= i/+ i/- i/* i// i/% i/> 0 1 1000000 %i (i/% 1000) id] - ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> 0.0 1.0 1000000.0 %r id math.floor] - ["Deg" r.deg d/= d/+ d/- d/* d// d/% d/> .0 ("lux deg max") ("lux deg max") %f id id] + ["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> +0 +1 +1000000 %n (n/% +1000) id] + ["Int" r.int i/= i/+ i/- i/* i// i/% i/> 0 1 1000000 %i (i/% 1000) id] + ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> 0.0 1.0 1000000.0 %r id math.floor] + ["Deg" r.deg d/= d/+ d/- d/* d// d/% d/> .0 (:! Deg -1) (:! Deg -1) %f id id] ) (do-template [category rand-gen -> <- = <cap> %a %z] diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux index 068e00523..6530fcb4a 100644 --- a/stdlib/test/test/lux/math/logic/fuzzy.lux +++ b/stdlib/test/test/lux/math/logic/fuzzy.lux @@ -50,8 +50,7 @@ (<gte> top sample)))) ))))] - ["Frac" number.Hash<Frac> r.frac &.f/triangle f/< f/<= f/> f/>=] - ["Deg" number.Hash<Deg> r.deg &.d/triangle d/< d/<= d/> d/>=] + ["Deg" number.Hash<Deg> r.deg &.triangle d/< d/<= d/> d/>=] ) (do-template [<desc> <hash> <gen> <trapezoid> <lt> <lte> <gt> <gte>] @@ -98,33 +97,23 @@ (<gte> top sample)))) ))))] - ["Frac" number.Hash<Frac> r.frac &.f/trapezoid f/< f/<= f/> f/>=] - ["Deg" number.Hash<Deg> r.deg &.d/trapezoid d/< d/<= d/> d/>=] + ["Deg" number.Hash<Deg> r.deg &.trapezoid d/< d/<= d/> d/>=] ) -(context: "Gaussian" - (<| (times +100) - (do @ - [deviation (|> r.frac (r.filter (f/> 0.0))) - center r.frac - #let [gaussian (&.gaussian deviation center)]] - (test "The center value will always have maximum membership." - (d/= ~true (&.membership center gaussian)))))) - (def: gen-triangle - (r.Random (&.Fuzzy Frac)) + (r.Random (&.Fuzzy Deg)) (do r.Monad<Random> - [x r.frac - y r.frac - z r.frac] - (wrap (&.f/triangle x y z)))) + [x r.deg + y r.deg + z r.deg] + (wrap (&.triangle x y z)))) (context: "Combinators" (<| (times +100) (do @ [left gen-triangle right gen-triangle - sample r.frac] + sample r.deg] ($_ seq (test "Union membership as as high as membership in any of its members." (let [combined (&.union left right) @@ -174,7 +163,7 @@ (<| (times +100) (do @ [fuzzy gen-triangle - sample r.frac + sample r.deg threshold r.deg #let [vip-fuzzy (&.cut threshold fuzzy) member? (&.to-predicate threshold fuzzy)]] |