Skip to content

Conversation

@bdeket
Copy link
Contributor

@bdeket bdeket commented Aug 21, 2025

too model all my failures
(or on brighter days - when to go surfing)

edit:
extra testfiles - weibulldist.zip

[x] implementation
[x] tests
[x] documentation
Copy link
Collaborator

@pavpanchekha pavpanchekha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really knowledgeable Weibull distributions specifically, but I did spot check the code and it looks good, and it's documented and tested, so in general I'm willing to merge. Any specific comments?

Comment on lines +36 to +49
(let ([sampler (make-weibull-sampler k)])
(values (make-weibull-pdf k)
(make-weibull-cdf k)
(make-weibull-inverse-cdf k)
(case-lambda:
[() (unsafe-flvector-ref (sampler 1) 0)]
[([n : Integer]) (flvector->list (sampler n))])))
(let ([sampler (make-weibull-sampler k d s)])
(values (make-weibull-pdf k d s)
(make-weibull-cdf k d s)
(make-weibull-inverse-cdf k d s)
(case-lambda:
[() (unsafe-flvector-ref (sampler 1) 0)]
[([n : Integer]) (flvector->list (sampler n))])))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to have the if statement on std? here? If I'm reading the code correctly, all of the make-weibull-pdf and similar functions can take three arguments and branch internally instead? Not a huge deal either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I can move the (and (= d 0) (= s 1)) test to the implementation side to avoid the extra wrapping when there is a std? call.
I think it is better to do it only once, here. If somebody would use the internal functions it is their responsibility to not use the 3 value version when not needed.
But I could change the 1 argument version to avoid the extra wrapping call and immediately use make-std-weibull-… functions.
Please let me know your preference.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, let's merge as is. I just wanted to understand what's up.

@bdeket
Copy link
Contributor Author

bdeket commented Sep 6, 2025

Thanks for looking into this.

Among other things the Weibull distribution is used for:

  • modelling material failures
  • modelling long term oceanic wave spectra (which I needed for my job)

Error:
Worst error observed in my test is now 10ulps (pdf) end in general less than 2 for the others
This has come at the cost of more branching and more uses of fl2 operations.

@pavpanchekha pavpanchekha merged commit 38ae0f4 into racket:master Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants