Skip to content

Commit

Permalink
add min/max methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lrnv committed Nov 17, 2023
1 parent 2d6d091 commit ce8f8fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "WilliamsonTransforms"
uuid = "48feb556-9bdd-43a2-8e10-96100ec25e22"
authors = ["Oskar Laverny <[email protected]> and contributors"]
version = "0.1.0"
version = "0.1.1"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
5 changes: 4 additions & 1 deletion src/WilliamsonTransforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Distributions
import TaylorSeries
import Base.minimum
import Roots
import Base: minimum, maximum

export 𝒲, 𝒲₋₁

Expand Down Expand Up @@ -110,12 +111,14 @@ function Distributions.cdf(d::𝒲₋₁, x::Real)
# return 1-rez
end
function Distributions.logpdf(d::𝒲₋₁, x::Real)
ϕ_d = taylor(d.ϕ, x, d.d+1, typeof(x))[end]
ϕ_d = max(taylor(d.ϕ, x, d.d+1, typeof(x))[end],0)
r = (d.d-1)*log(x) - sum(log.(1:(d.d-1)))
return log(ϕ_d) + r
end
function Distributions.rand(rng::Distributions.AbstractRNG, d::𝒲₋₁)
u = rand(rng)
Roots.find_zero(x -> (Distributions.cdf(d,x) - u), (0.0, Inf))
end
Base.minimum(::𝒲₋₁) = 0.0
Base.maximum(::𝒲₋₁) = Inf
end

2 comments on commit ce8f8fd

@lrnv
Copy link
Owner Author

@lrnv lrnv commented on ce8f8fd Nov 17, 2023

Choose a reason for hiding this comment

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

@JuliaRegistrator register

Release notes:
Add a method

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/95486

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" ce8f8fd35e02f3d9f1090743ba2a1acf8d785703
git push origin v0.1.1

Please sign in to comment.