-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Distributions #871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Distributions #871
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
Wonderful! You got really far before you got tired. That was my problem the other night too and all I was doing was inserting stub definitions from wikipedia — this is much more substantial. |
StefanKarpinski
added a commit
that referenced
this pull request
May 24, 2012
Actual working code for probability distributions from Doug Bates.
Member
|
I love it: julia> Normal()
Normal(0.0,1.0)
julia> pdf(Normal(),1.0)
0.24197072451914337
julia> pdf(Normal(),0.0)
0.3989422804014327
julia> cdf(Normal(),0.0)
0.5
julia> cdf(Normal(),1.0)
0.797939722603012
julia> ccdf(Normal(),1.0)
0.15865525393145705 |
ericphanson
added a commit
to ericphanson/julia
that referenced
this pull request
Sep 3, 2021
```julia
julia> f(i) = (sleep(i); i == 5 && error("5"))
f (generic function with 1 method)
julia> asyncmap(f, 1:5) # master
ERROR: 5
Stacktrace:
[1] (::Base.var"JuliaLang#881#883")(x::Task)
@ Base ./asyncmap.jl:177
[2] foreach(f::Base.var"JuliaLang#881#883", itr::Vector{Any})
@ Base ./abstractarray.jl:2606
[3] maptwice(wrapped_f::Function, chnl::Channel{Any}, worker_tasks::Vector{Any}, c::UnitRange{Int64})
@ Base ./asyncmap.jl:177
[4] wrap_n_exec_twice
@ ./asyncmap.jl:153 [inlined]
[5] async_usemap(f::typeof(f), c::UnitRange{Int64}; ntasks::Int64, batch_size::Nothing)
@ Base ./asyncmap.jl:103
[6] #asyncmap#865
@ ./asyncmap.jl:81 [inlined]
[7] asyncmap(f::Function, c::UnitRange{Int64})
@ Base ./asyncmap.jl:81
[8] top-level scope
@ REPL[4]:1
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing) # monkeypatch
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
batch_collection=Any[]
n = 0
for exec_data in chnl
push!(batch_collection, exec_data)
n += 1
(n == batch_size) && break
end
if n > 0
exec_func(batch_collection)
end
end
else
for exec_data in chnl
exec_func(exec_data...)
end
end
catch e
close(chnl)
Base.display_error(stderr, Base.catch_stack())
retval = e
end
retval
end
push!(worker_tasks, t)
end
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing)
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing)
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
julia> asyncmap(f, 1:5) # post-patch
ERROR: 5
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] f
@ ./REPL[3]:1 [inlined]
[3] (::Base.var"JuliaLang#871#876"{typeof(f)})(r::Base.RefValue{Any}, args::Tuple{Int64})
@ Base ./asyncmap.jl:100
[4] macro expansion
@ ./REPL[5]:23 [inlined]
[5] (::var"JuliaLang#1#2"{Base.var"JuliaLang#871#876"{typeof(f)}, Channel{Any}, Nothing})()
@ Main ./task.jl:411
ERROR: 5
Stacktrace:
[1] (::Base.var"JuliaLang#881#883")(x::Task)
@ Base ./asyncmap.jl:177
[2] foreach(f::Base.var"JuliaLang#881#883", itr::Vector{Any})
@ Base ./abstractarray.jl:2606
[3] maptwice(wrapped_f::Function, chnl::Channel{Any}, worker_tasks::Vector{Any}, c::UnitRange{Int64})
@ Base ./asyncmap.jl:177
[4] wrap_n_exec_twice
@ ./asyncmap.jl:153 [inlined]
[5] async_usemap(f::typeof(f), c::UnitRange{Int64}; ntasks::Int64, batch_size::Nothing)
@ Base ./asyncmap.jl:103
[6] #asyncmap#865
@ ./asyncmap.jl:81 [inlined]
[7] asyncmap(f::Function, c::UnitRange{Int64})
@ Base ./asyncmap.jl:81
[8] top-level scope
@ REPL[6]:1
```
ericphanson
added a commit
to ericphanson/julia
that referenced
this pull request
Dec 28, 2021
```julia
julia> f(i) = (sleep(i); i == 5 && error("5"))
f (generic function with 1 method)
julia> asyncmap(f, 1:5) # master
ERROR: 5
Stacktrace:
[1] (::Base.var"JuliaLang#881#883")(x::Task)
@ Base ./asyncmap.jl:177
[2] foreach(f::Base.var"JuliaLang#881#883", itr::Vector{Any})
@ Base ./abstractarray.jl:2606
[3] maptwice(wrapped_f::Function, chnl::Channel{Any}, worker_tasks::Vector{Any}, c::UnitRange{Int64})
@ Base ./asyncmap.jl:177
[4] wrap_n_exec_twice
@ ./asyncmap.jl:153 [inlined]
[5] async_usemap(f::typeof(f), c::UnitRange{Int64}; ntasks::Int64, batch_size::Nothing)
@ Base ./asyncmap.jl:103
[6] #asyncmap#865
@ ./asyncmap.jl:81 [inlined]
[7] asyncmap(f::Function, c::UnitRange{Int64})
@ Base ./asyncmap.jl:81
[8] top-level scope
@ REPL[4]:1
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing) # monkeypatch
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
batch_collection=Any[]
n = 0
for exec_data in chnl
push!(batch_collection, exec_data)
n += 1
(n == batch_size) && break
end
if n > 0
exec_func(batch_collection)
end
end
else
for exec_data in chnl
exec_func(exec_data...)
end
end
catch e
close(chnl)
Base.display_error(stderr, Base.catch_stack())
retval = e
end
retval
end
push!(worker_tasks, t)
end
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing)
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing)
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
julia> asyncmap(f, 1:5) # post-patch
ERROR: 5
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] f
@ ./REPL[3]:1 [inlined]
[3] (::Base.var"JuliaLang#871#876"{typeof(f)})(r::Base.RefValue{Any}, args::Tuple{Int64})
@ Base ./asyncmap.jl:100
[4] macro expansion
@ ./REPL[5]:23 [inlined]
[5] (::var"JuliaLang#1#2"{Base.var"JuliaLang#871#876"{typeof(f)}, Channel{Any}, Nothing})()
@ Main ./task.jl:411
ERROR: 5
Stacktrace:
[1] (::Base.var"JuliaLang#881#883")(x::Task)
@ Base ./asyncmap.jl:177
[2] foreach(f::Base.var"JuliaLang#881#883", itr::Vector{Any})
@ Base ./abstractarray.jl:2606
[3] maptwice(wrapped_f::Function, chnl::Channel{Any}, worker_tasks::Vector{Any}, c::UnitRange{Int64})
@ Base ./asyncmap.jl:177
[4] wrap_n_exec_twice
@ ./asyncmap.jl:153 [inlined]
[5] async_usemap(f::typeof(f), c::UnitRange{Int64}; ntasks::Int64, batch_size::Nothing)
@ Base ./asyncmap.jl:103
[6] #asyncmap#865
@ ./asyncmap.jl:81 [inlined]
[7] asyncmap(f::Function, c::UnitRange{Int64})
@ Base ./asyncmap.jl:81
[8] top-level scope
@ REPL[6]:1
```
ericphanson
added a commit
to ericphanson/julia
that referenced
this pull request
Jan 4, 2022
```julia
julia> f(i) = (sleep(i); i == 5 && error("5"))
f (generic function with 1 method)
julia> asyncmap(f, 1:5) # master
ERROR: 5
Stacktrace:
[1] (::Base.var"JuliaLang#881#883")(x::Task)
@ Base ./asyncmap.jl:177
[2] foreach(f::Base.var"JuliaLang#881#883", itr::Vector{Any})
@ Base ./abstractarray.jl:2606
[3] maptwice(wrapped_f::Function, chnl::Channel{Any}, worker_tasks::Vector{Any}, c::UnitRange{Int64})
@ Base ./asyncmap.jl:177
[4] wrap_n_exec_twice
@ ./asyncmap.jl:153 [inlined]
[5] async_usemap(f::typeof(f), c::UnitRange{Int64}; ntasks::Int64, batch_size::Nothing)
@ Base ./asyncmap.jl:103
[6] #asyncmap#865
@ ./asyncmap.jl:81 [inlined]
[7] asyncmap(f::Function, c::UnitRange{Int64})
@ Base ./asyncmap.jl:81
[8] top-level scope
@ REPL[4]:1
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing) # monkeypatch
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
batch_collection=Any[]
n = 0
for exec_data in chnl
push!(batch_collection, exec_data)
n += 1
(n == batch_size) && break
end
if n > 0
exec_func(batch_collection)
end
end
else
for exec_data in chnl
exec_func(exec_data...)
end
end
catch e
close(chnl)
Base.display_error(stderr, Base.catch_stack())
retval = e
end
retval
end
push!(worker_tasks, t)
end
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing)
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
julia> function Base.start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing)
t = @async begin
retval = nothing
try
if isa(batch_size, Number)
while isopen(chnl)
# The mapping function expects an array of input args, as it processes
# elements in a batch.
julia> asyncmap(f, 1:5) # post-patch
ERROR: 5
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] f
@ ./REPL[3]:1 [inlined]
[3] (::Base.var"JuliaLang#871#876"{typeof(f)})(r::Base.RefValue{Any}, args::Tuple{Int64})
@ Base ./asyncmap.jl:100
[4] macro expansion
@ ./REPL[5]:23 [inlined]
[5] (::var"JuliaLang#1#2"{Base.var"JuliaLang#871#876"{typeof(f)}, Channel{Any}, Nothing})()
@ Main ./task.jl:411
ERROR: 5
Stacktrace:
[1] (::Base.var"JuliaLang#881#883")(x::Task)
@ Base ./asyncmap.jl:177
[2] foreach(f::Base.var"JuliaLang#881#883", itr::Vector{Any})
@ Base ./abstractarray.jl:2606
[3] maptwice(wrapped_f::Function, chnl::Channel{Any}, worker_tasks::Vector{Any}, c::UnitRange{Int64})
@ Base ./asyncmap.jl:177
[4] wrap_n_exec_twice
@ ./asyncmap.jl:153 [inlined]
[5] async_usemap(f::typeof(f), c::UnitRange{Int64}; ntasks::Int64, batch_size::Nothing)
@ Base ./asyncmap.jl:103
[6] #asyncmap#865
@ ./asyncmap.jl:81 [inlined]
[7] asyncmap(f::Function, c::UnitRange{Int64})
@ Base ./asyncmap.jl:81
[8] top-level scope
@ REPL[6]:1
```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
updates to base/distributions.jl to use the libRmath C functions for pdf, etc. as discussed in issue #859