functions: Add tbf.
This commit is contained in:
parent
6247f28958
commit
e237e9e019
1 changed files with 19 additions and 1 deletions
|
@ -10,6 +10,9 @@
|
|||
(require "utils.rkt")
|
||||
|
||||
(provide
|
||||
;; Structures
|
||||
(contract-out
|
||||
[struct tbf ((weights number?) (threshold (vectorof number?)))])
|
||||
;; Functions
|
||||
(contract-out
|
||||
[tabulate (-> procedure? (listof generic-set?) (listof list?))]
|
||||
|
@ -23,7 +26,9 @@
|
|||
[enumerate-boolean-functions/list (-> number? (stream/c procedure?))]
|
||||
[random-boolean-table (-> number? (listof (*list/c boolean? boolean?)))]
|
||||
[random-boolean-function (-> number? procedure?)]
|
||||
[random-boolean-function/list (-> number? procedure?)]))
|
||||
[random-boolean-function/list (-> number? procedure?)]
|
||||
[tbf-w (-> tbf? (vectorof number?))]
|
||||
[tbf-θ (-> tbf? number?)]))
|
||||
|
||||
(module+ test
|
||||
(require rackunit))
|
||||
|
@ -197,3 +202,16 @@
|
|||
(define f (random-boolean-function/list 2))
|
||||
(check-false (f '(#f #f))) (check-true (f '(#f #t)))
|
||||
(check-true (f '(#t #f))) (check-false (f '(#t #t)))))
|
||||
|
||||
|
||||
;;; ===========================
|
||||
;;; Threshold Boolean functions
|
||||
;;; ===========================
|
||||
|
||||
;;; A threshold Boolean function (TBF) is a pair (w, θ), where w is a
|
||||
;;; vector of weights and θ is the threshold.
|
||||
(struct tbf (weights threshold) #:transparent)
|
||||
|
||||
;;; Unicode shortcuts for accessing the elements of a TBF.
|
||||
(define tbf-w tbf-weights)
|
||||
(define tbf-θ tbf-threshold)
|
||||
|
|
Loading…
Reference in a new issue