(module ss-funcs mzscheme
(require "data-synthesis.ss"
"distributions.ss"
(only (lib "frtime.ss" "frtime") undefined?)
)
(define (filter pred lst)
(cond [(null? lst) '()]
[(pred (car lst))
(cons (car lst)
(filter pred (cdr lst)))]
[else (filter pred (cdr lst))]))
(define (count pred lst)
(cond [(null? lst) 0]
[(pred (car lst))
(+ 1 (count pred (cdr lst)))]
[else (count pred (cdr lst))]))
(define (filter-out-undefined lst)
(filter (lambda (o)
(not (undefined? o)))
lst))
(define (count-undefineds lst)
(count undefined? lst))
(define (name->dist-fit-func name)
(cond [(equal? name 'uniform)
fit-uniform-distribution]
[(equal? name 'normal)
fit-normal-distribution]
[(equal? name 'exponential)
fit-exponential-distribution]
[else (raise (format "~a not an allowable distribution name"))]))
(define (replace pred lst filler)
(cond [(null? lst)
'()]
[(not (pred (car lst)))
(cons (car lst)
(replace pred
(cdr lst)
filler))]
[(null? filler)
(raise "not enough filler to complete replace function")]
[(pred (car lst))
(cons (car filler)
(replace pred
(cdr lst)
(cdr filler)))]))
(define (replace-from-generator pred lst gen)
(cond [(null? lst)
'()]
[(not (pred (car lst)))
(cons (car lst)
(replace-from-generator pred
(cdr lst)
gen))]
[(pred (car lst))
(cons (gen)
(replace-from-generator pred
(cdr lst)
gen))]))
(define (inflate-data dist-name data)
(replace-from-generator undefined?
data
(distribution-rand ((name->dist-fit-func dist-name)
(filter-out-undefined data)))))
(provide inflate-data)
)