Skip to content

Commit 38ae0f4

Browse files
authored
Weibull-distribution (#114)
[x] implementation [x] tests [x] documentation
1 parent 32e9ee4 commit 38ae0f4

File tree

5 files changed

+639
-0
lines changed

5 files changed

+639
-0
lines changed

math-doc/math/scribblings/math-distributions.scrbl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,41 @@ choice is
619619
Therefore, a gamma distribution with @racket[shape = 0] behaves like @racket[(delta-dist 0)].
620620
}
621621

622+
@subsection{Weibull Distributions}
623+
624+
@margin-note{Wikipedia:
625+
@hyperlink["http://wikipedia.org/wiki/Weibull_distribution"]{Weibull Distribution}.}
626+
@deftogether[(@defidform[Weibull-Dist]
627+
@defproc[(weibull-dist [shape Positive-Real] [location Real 0] [scale Real 1]) Weibull-Dist]
628+
@defproc[(weibull-dist-shape [k Weibull-Dist]) Positive-Flonum]
629+
@defproc[(weibull-dist-location [d Weibull-Dist]) Real]
630+
@defproc[(weibull-dist-scale [d Weibull-Dist]) Real])]{
631+
Represents the Weibull distribution family parameterized by shape, location and scale.
632+
633+
@examples[#:eval untyped-eval
634+
(plot (for/list ([k (in-list '(1/2 1 1 5))]
635+
[d (in-list '(0 0 3/2 0))]
636+
[s (in-list '(1 1 2 1))]
637+
[i (in-naturals)])
638+
(function (distribution-pdf (weibull-dist k d s))
639+
#:color i #:label (if (and (= d 0) (= s 1))
640+
(format "Weibull(~a)" k)
641+
(format "Weibull(~a,~a,~a)" k d s))))
642+
#:x-min 0 #:x-max 6 #:y-label "density"
643+
#:legend-anchor 'top-right)
644+
645+
(plot (for/list ([k (in-list '(1/2 1 1 5))]
646+
[d (in-list '(0 0 3/2 0))]
647+
[s (in-list '(1 1 2 1))]
648+
[i (in-naturals)])
649+
(function (ordered-dist-cdf (weibull-dist k d s))
650+
#:color i #:label (if (and (= d 0) (= s 1))
651+
(format "Weibull(~a)" k)
652+
(format "Weibull(~a,~a,~a)" k d s))))
653+
#:x-min 0 #:x-max 10 #:y-label "probability"
654+
#:legend-anchor 'bottom-right)]
655+
}
656+
622657
@subsection{Logistic Distributions}
623658

624659
@margin-note{Wikipedia:

math-lib/math/distributions.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"private/distributions/normal-dist.rkt"
1111
"private/distributions/exponential-dist.rkt"
1212
"private/distributions/gamma-dist.rkt"
13+
"private/distributions/weibull-dist.rkt"
1314
"private/distributions/beta-dist.rkt"
1415
"private/distributions/truncated-dist.rkt"
1516
"private/distributions/geometric-dist.rkt"
@@ -30,6 +31,7 @@
3031
"private/distributions/normal-dist.rkt"
3132
"private/distributions/exponential-dist.rkt"
3233
"private/distributions/gamma-dist.rkt"
34+
"private/distributions/weibull-dist.rkt"
3335
"private/distributions/beta-dist.rkt"
3436
"private/distributions/truncated-dist.rkt"
3537
"private/distributions/geometric-dist.rkt"

0 commit comments

Comments
 (0)