Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
style = "sciml"
style = "sciml"
format_markdown = true
37 changes: 15 additions & 22 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
The PoissonRandom.jl package is licensed under the MIT "Expat" License:

> Copyright (c) 2018: Christopher Rackauckas.
>
>
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
>
>
> of this software and associated documentation files (the "Software"), to deal
>
>
> in the Software without restriction, including without limitation the rights
>
>
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>
>
> copies of the Software, and to permit persons to whom the Software is
>
>
> furnished to do so, subject to the following conditions:
>
>
>
>
> The above copyright notice and this permission notice shall be included in all
>
>
> copies or substantial portions of the Software.
>
>
>
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>
>
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>
>
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
>
>
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>
>
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
>
>
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
>
>
> SOFTWARE.
>
>

All of this code is derived from JuliaStats/Distributions.jl
69 changes: 35 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![codecov](https://codecov.io/gh/SciML/PoissonRandom.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/PoissonRandom.jl)
[![Build Status](https://github.com/SciML/PoissonRandom.jl/workflows/CI/badge.svg)](https://github.com/SciML/PoissonRandom.jl/actions?query=workflow%3ACI)

[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)

## Tutorials and Documentation
Expand All @@ -27,7 +27,7 @@ pois_rand(λ)
# Using another RNG
using RandomNumbers
rng = Xorshifts.Xoroshiro128Plus()
pois_rand(rng,λ)
pois_rand(rng, λ)
```

## Implementation
Expand All @@ -38,52 +38,53 @@ See [this blog post for details](https://www.johndcook.com/blog/2010/06/14/gener
## Benchmark

```julia
using RandomNumbers, Distributions, BenchmarkTools, StaticArrays,
RecursiveArrayTools, Plots, PoissonRandom
labels = ["count_rand","ad_rand","pois_rand","Distributions.jl"]
using RandomNumbers,
Distributions, BenchmarkTools, StaticArrays,
RecursiveArrayTools, Plots, PoissonRandom
labels = ["count_rand", "ad_rand", "pois_rand", "Distributions.jl"]
rng = Xorshifts.Xoroshiro128Plus()

function n_count(rng,λ,n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.count_rand(rng,λ)
end
function n_count(rng, λ, n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.count_rand(rng, λ)
end
end

function n_pois(rng,λ,n)
tmp = 0
for i in 1:n
tmp += pois_rand(rng,λ)
end
function n_pois(rng, λ, n)
tmp = 0
for i in 1:n
tmp += pois_rand(rng, λ)
end
end

function n_ad(rng,λ,n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.ad_rand(rng,λ)
end
function n_ad(rng, λ, n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.ad_rand(rng, λ)
end
end

function n_dist(λ,n)
tmp = 0
for i in 1:n
tmp += rand(Poisson(λ))
end
function n_dist(λ, n)
tmp = 0
for i in 1:n
tmp += rand(Poisson(λ))
end
end

function time_λ(rng,λ,n)
t1 = @elapsed n_count(rng,λ,n)
t2 = @elapsed n_ad(rng,λ,n)
t3 = @elapsed n_pois(rng,λ,n)
t4 = @elapsed n_dist(λ,n)
@SArray [t1,t2,t3,t4]
function time_λ(rng, λ, n)
t1 = @elapsed n_count(rng, λ, n)
t2 = @elapsed n_ad(rng, λ, n)
t3 = @elapsed n_pois(rng, λ, n)
t4 = @elapsed n_dist(λ, n)
@SArray [t1, t2, t3, t4]
end

# Compile
time_λ(rng,5,5000000)
time_λ(rng, 5, 5000000)
# Run with a bunch of λ
times = VectorOfArray([time_λ(rng,n,5000000) for n in 1:20])'
plot(times,labels = labels, lw = 3)
times = VectorOfArray([time_λ(rng, n, 5000000) for n in 1:20])'
plot(times, labels = labels, lw = 3)
```

![benchmark result](https://user-images.githubusercontent.com/1814174/40387004-1e377776-5dc0-11e8-88a2-2d9cb12db984.png)
Expand Down
25 changes: 17 additions & 8 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
include("pages.jl")

makedocs(sitename = "PoissonRandom.jl",
authors = "Chris Rackauckas",
modules = [PoissonRandom],
clean = true, doctest = false,
format = Documenter.HTML(analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/PoissonRandom/stable/"),
pages = pages)
authors = "Chris Rackauckas",
modules = [PoissonRandom],
clean = true, doctest = false, linkcheck = true,
strict = [
:doctest,
:linkcheck,
:parse_error,
:example_block,
:cross_references,
# Other available options are
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
],
format = Documenter.HTML(analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/PoissonRandom/stable/"),
pages = pages)

deploydocs(repo = "github.com/SciML/PoissonRandom.jl.git";
push_preview = true)
push_preview = true)
120 changes: 71 additions & 49 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pois_rand(λ)
# Using another RNG
using RandomNumbers
rng = Xorshifts.Xoroshiro128Plus()
pois_rand(rng,λ)
pois_rand(rng, λ)
```

## Implementation
Expand All @@ -32,121 +32,143 @@ See [this blog post for details](https://www.johndcook.com/blog/2010/06/14/gener
## Benchmark

```julia
using RandomNumbers, Distributions, BenchmarkTools, StaticArrays,
RecursiveArrayTools, Plots, PoissonRandom
labels = ["count_rand","ad_rand","pois_rand","Distributions.jl"]
using RandomNumbers,
Distributions, BenchmarkTools, StaticArrays,
RecursiveArrayTools, Plots, PoissonRandom
labels = ["count_rand", "ad_rand", "pois_rand", "Distributions.jl"]
rng = Xorshifts.Xoroshiro128Plus()

function n_count(rng,λ,n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.count_rand(rng,λ)
end
function n_count(rng, λ, n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.count_rand(rng, λ)
end
end

function n_pois(rng,λ,n)
tmp = 0
for i in 1:n
tmp += pois_rand(rng,λ)
end
function n_pois(rng, λ, n)
tmp = 0
for i in 1:n
tmp += pois_rand(rng, λ)
end
end

function n_ad(rng,λ,n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.ad_rand(rng,λ)
end
function n_ad(rng, λ, n)
tmp = 0
for i in 1:n
tmp += PoissonRandom.ad_rand(rng, λ)
end
end

function n_dist(λ,n)
tmp = 0
for i in 1:n
tmp += rand(Poisson(λ))
end
function n_dist(λ, n)
tmp = 0
for i in 1:n
tmp += rand(Poisson(λ))
end
end

function time_λ(rng,λ,n)
t1 = @elapsed n_count(rng,λ,n)
t2 = @elapsed n_ad(rng,λ,n)
t3 = @elapsed n_pois(rng,λ,n)
t4 = @elapsed n_dist(λ,n)
@SArray [t1,t2,t3,t4]
function time_λ(rng, λ, n)
t1 = @elapsed n_count(rng, λ, n)
t2 = @elapsed n_ad(rng, λ, n)
t3 = @elapsed n_pois(rng, λ, n)
t4 = @elapsed n_dist(λ, n)
@SArray [t1, t2, t3, t4]
end

# Compile
time_λ(rng,5,5000000)
time_λ(rng, 5, 5000000)
# Run with a bunch of λ
times = VectorOfArray([time_λ(rng,n,5000000) for n in 1:20])'
plot(times,labels = labels, lw = 3)
times = VectorOfArray([time_λ(rng, n, 5000000) for n in 1:20])'
plot(times, labels = labels, lw = 3)
```

![benchmark result](https://user-images.githubusercontent.com/1814174/40387004-1e377776-5dc0-11e8-88a2-2d9cb12db984.png)

So this package ends up about 30% or so faster than Distributions.jl (the method
at the far edge is λ-independent so that goes on forever).
at the far edge is λ-independent, so that goes on forever).

## Contributing

- Please refer to the
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
for guidance on PRs, issues, and other matters relating to contributing to SciML.
- There are a few community forums:
- the #diffeq-bridged channel in the [Julia Slack](https://julialang.org/slack/)
- [JuliaDiffEq](https://gitter.im/JuliaDiffEq/Lobby) on Gitter
- on the [Julia Discourse forums](https://discourse.julialang.org)
- see also [SciML Community page](https://sciml.ai/community/)
- Please refer to the
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
for guidance on PRs, issues, and other matters relating to contributing to SciML.

- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
- There are a few community forums:

+ The #diffeq-bridged and #sciml-bridged channels in the
[Julia Slack](https://julialang.org/slack/)
+ The #diffeq-bridged and #sciml-bridged channels in the
[Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
+ On the [Julia Discourse forums](https://discourse.julialang.org)
+ See also [SciML Community page](https://sciml.ai/community/)

## Reproducibility

```@raw html
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
```

```@example
using Pkg # hide
Pkg.status() # hide
```

```@raw html
</details>
```

```@raw html
<details><summary>and using this machine and Julia version.</summary>
```

```@example
using InteractiveUtils # hide
versioninfo() # hide
```

```@raw html
</details>
```

```@raw html
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
```

```@example
using Pkg # hide
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
```

```@raw html
</details>
```

```@raw html
You can also download the
<a href="
```

```@eval
using TOML
version = TOML.parse(read("../../Project.toml",String))["version"]
name = TOML.parse(read("../../Project.toml",String))["name"]
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Manifest.toml"
version = TOML.parse(read("../../Project.toml", String))["version"]
name = TOML.parse(read("../../Project.toml", String))["name"]
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
"/assets/Manifest.toml"
```

```@raw html
">manifest</a> file and the
<a href="
```

```@eval
using TOML
version = TOML.parse(read("../../Project.toml",String))["version"]
name = TOML.parse(read("../../Project.toml",String))["name"]
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Project.toml"
version = TOML.parse(read("../../Project.toml", String))["version"]
name = TOML.parse(read("../../Project.toml", String))["name"]
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
"/assets/Project.toml"
```

```@raw html
">project</a> file.
```
Loading