Most of the functions from BUGS have been implemented.
JuliaBUGS directly utilizes functions from the Julia Standard Library when they share the same names and functionalities. For functions not available in the Julia Standard Library and other popular libraries, we have developed equivalents within JuliaBUGS.BUGSPrimitives.
Function defined in Julia Standard Library
Please note that some functions listed may accept additional arguments (e.g. trunc) and/or keyword arguments (e.g. sum, sort, mean). However, at the moment JuliaBUGS only supports function arguments of type Real or AbstractArray{Real}. Furthermore, JuliaBUGS does not accommodate the use of keyword argument syntax. Thus, the default values for any optional or keyword arguments will be automatically applied.
Base.abs — Function
abs(x)The absolute value of x.
When abs is applied to signed integers, overflow may occur, resulting in the return of a negative value. This overflow occurs only when abs is applied to the minimum representable value of a signed integer. That is, when x == typemin(typeof(x)), abs(x) == x < 0, not -x as might be expected.
See also: abs2, unsigned, sign.
Examples
julia> abs(-3)
3
julia> abs(1 + im)
1.4142135623730951
julia> abs.(Int8[-128 -127 -126 0 126 127]) # overflow at typemin(Int8)
1×6 Matrix{Int8}:
-128 127 126 0 126 127
julia> maximum(abs, [1, -2, 3, -4])
4sourceBase.log — Method
log(x)Compute the natural logarithm of x.
Throw a DomainError for negative Real arguments. Use Complex arguments to obtain Complex results.
See also ℯ, log1p, log2, log10.
Examples
julia> log(2)
0.6931471805599453
julia> log(-3)
ERROR: DomainError with -3.0:
log was called with a negative real argument but will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
[1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]
julia> log(-3 + 0im)
1.0986122886681098 + 3.141592653589793im
julia> log(-3 - 0.0im)
1.0986122886681098 - 3.141592653589793im
julia> log.(exp.(-1:1))
3-element Vector{Float64}:
-1.0
0.0
1.0sourceBase.sqrt — Method
sqrt(x)Return $\sqrt{x}$.
Throw a DomainError for negative Real arguments. Use Complex negative arguments instead to obtain a Complex result.
The prefix operator √ is equivalent to sqrt.
See also: hypot.
Examples
julia> sqrt(big(81))
9.0
julia> sqrt(big(-81))
ERROR: DomainError with -81.0:
NaN result for non-NaN input.
Stacktrace:
[1] sqrt(::BigFloat) at ./mpfr.jl:501
[...]
julia> sqrt(big(complex(-81)))
0.0 + 9.0im
julia> sqrt(-81 - 0.0im) # -0.0im is below the branch cut
0.0 - 9.0im
julia> .√(1:4)
4-element Vector{Float64}:
1.0
1.4142135623730951
1.7320508075688772
2.0sourceBase.trunc — Function
trunc([T,] x)
trunc(x; digits::Integer= [, base = 10])
trunc(x; sigdigits::Integer= [, base = 10])trunc(x) returns the nearest integral value of the same type as x whose absolute value is less than or equal to the absolute value of x.
trunc(T, x) converts the result to type T, throwing an InexactError if the truncated value is not representable a T.
Keywords digits, sigdigits and base work as for round.
To support trunc for a new type, define Base.round(x::NewType, ::RoundingMode{:ToZero}).
See also: %, floor, unsigned, unsafe_trunc.
Examples
julia> trunc(2.22)
2.0
julia> trunc(-2.22, digits=1)
-2.2
julia> trunc(Int, -2.22)
-2sourceBase.sort — Method
sort(A; dims::Integer, alg::Base.Sort.Algorithm=Base.Sort.defalg(A), lt=isless, by=identity, rev::Bool=false, order::Base.Order.Ordering=Base.Order.Forward)Sort a multidimensional array A along the given dimension. See sort! for a description of possible keyword arguments.
To sort slices of an array, refer to sortslices.
Examples
julia> A = [4 3; 1 2]
2×2 Matrix{Int64}:
4 3
1 2
julia> sort(A, dims = 1)
2×2 Matrix{Int64}:
1 2
4 3
julia> sort(A, dims = 2)
2×2 Matrix{Int64}:
3 4
1 2sourceBase.sin — Method
sin(x::T) where {T <: Number} -> float(T)Compute sine of x, where x is in radians.
Throw a DomainError if isinf(x), return a T(NaN) if isnan(x).
See also sind, sinpi, sincos, cis, asin.
Examples
julia> round.(sin.(range(0, 2pi, length=9)'), digits=3)
1×9 Matrix{Float64}:
0.0 0.707 1.0 0.707 0.0 -0.707 -1.0 -0.707 -0.0
julia> sind(45)
0.7071067811865476
julia> sinpi(1/4)
0.7071067811865475
julia> round.(sincos(pi/6), digits=3)
(0.5, 0.866)
julia> round(cis(pi/6), digits=3)
0.866 + 0.5im
julia> round(exp(im*pi/6), digits=3)
0.866 + 0.5imsourceBase.tan — Method
tan(x::T) where {T <: Number} -> float(T)Compute tangent of x, where x is in radians.
Throw a DomainError if isinf(x), return a T(NaN) if isnan(x).
See also tanh.
Base.asin — Method
asin(x::T) where {T <: Number} -> float(T)Compute the inverse sine of x, where the output is in radians.
Return a T(NaN) if isnan(x).
See also asind for output in degrees.
Examples
julia> asin.((0, 1/2, 1))
(0.0, 0.5235987755982989, 1.5707963267948966)
julia> asind.((0, 1/2, 1))
(0.0, 30.000000000000004, 90.0)sourceBase.atan — Method
atan(y)
atan(y, x)Compute the inverse tangent of y or y/x, respectively.
For one real argument, this is the angle in radians between the positive x-axis and the point (1, y), returning a value in the interval $[-\pi/2, \pi/2]$.
For two arguments, this is the angle in radians between the positive x-axis and the point (x, y), returning a value in the interval $[-\pi, \pi]$. This corresponds to a standard atan2 function. Note that by convention atan(0.0,x) is defined as $\pi$ and atan(-0.0,x) is defined as $-\pi$ when x < 0.
See also atand for degrees.
Examples
julia> rad2deg(atan(-1/√3))
-30.000000000000004
julia> rad2deg(atan(-1, √3))
-30.000000000000004
julia> rad2deg(atan(1, -√3))
150.0sourceBase.asinh — Method
Base.acosh — Method
Base.atanh — Method
Statistics.mean — Method
mean(A::AbstractArray; dims)Compute the mean of an array over the given dimensions.
Examples
julia> using Statistics
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> mean(A, dims=1)
1×2 Matrix{Float64}:
2.0 3.0
julia> mean(A, dims=2)
2×1 Matrix{Float64}:
1.5
3.5sourceFunction defined in LogExpFunctions
LogExpFunctions.cloglog — Function
LogExpFunctions.cexpexp — Function
LogExpFunctions.logit — Function
LogExpFunctions.logistic — Function
Function defined in JuliaBUGS.BUGSPrimitives
JuliaBUGS.BUGSPrimitives.equals — Function
JuliaBUGS.BUGSPrimitives.inprod — Function
JuliaBUGS.BUGSPrimitives.inverse — Function
JuliaBUGS.BUGSPrimitives.logdet — Function
JuliaBUGS.BUGSPrimitives.logfact — Function
JuliaBUGS.BUGSPrimitives.loggam — Function
JuliaBUGS.BUGSPrimitives.icloglog — Function
JuliaBUGS.BUGSPrimitives.ilogit — Function
JuliaBUGS.BUGSPrimitives.mexp — Function
JuliaBUGS.BUGSPrimitives.phi — Function
phi(x)Cumulative distribution function (CDF) of the standard normal distribution evaluated at $x$.
sourceJuliaBUGS.BUGSPrimitives.probit — Function
JuliaBUGS.BUGSPrimitives.pow — Function
JuliaBUGS.BUGSPrimitives.rank — Function
JuliaBUGS.BUGSPrimitives.ranked — Function
ranked(v::AbstractVector, i::Integer)Return the $i$-th element of $\mathbf{v}$ sorted in ascending order.
source