diff --git a/.travis.yml b/.travis.yml index 0654335..149eb81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,9 @@ language: julia julia: - - 1.1 + - 1.0 + - 1.2 + - nightly os: - linux @@ -15,9 +17,10 @@ addons: notifications: email: false -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia --project --check-bounds=yes -e 'import Pkg; Pkg.build(; verbose=true); Pkg.test(; coverage=true);' +matrix: + fast_finish: true + allow_failures: + - julia: nightly after_success: - julia --project -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder());' diff --git a/Manifest.toml b/Manifest.toml deleted file mode 100644 index ee29ced..0000000 --- a/Manifest.toml +++ /dev/null @@ -1,386 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -[[AbstractFFTs]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "380e36c66edfa099cd90116b24c1ce8cafccac40" -uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" -version = "0.4.1" - -[[Arpack]] -deps = ["BinaryProvider", "Libdl", "LinearAlgebra", "Random", "SparseArrays", "Test"] -git-tree-sha1 = "1ce1ce9984683f0b6a587d5bdbc688ecb480096f" -uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97" -version = "0.3.0" - -[[AxisAlgorithms]] -deps = ["Compat", "WoodburyMatrices"] -git-tree-sha1 = "99dabbe853e4f641ab21a676131f2cf9fb29937e" -uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950" -version = "0.3.0" - -[[Base64]] -uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" - -[[BinDeps]] -deps = ["Compat", "Libdl", "SHA", "URIParser"] -git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" -uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" -version = "0.8.10" - -[[BinaryProvider]] -deps = ["Libdl", "SHA"] -git-tree-sha1 = "c7361ce8a2129f20b0e05a89f7070820cfed6648" -uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.5.4" - -[[Calculus]] -deps = ["Compat"] -git-tree-sha1 = "f60954495a7afcee4136f78d1d60350abd37a409" -uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" -version = "0.4.1" - -[[Clustering]] -deps = ["Dates", "Distances", "LinearAlgebra", "NearestNeighbors", "Printf", "Random", "SparseArrays", "Statistics", "StatsBase", "Test"] -git-tree-sha1 = "5c4c26ffc9075f5a425efdc6e40c6f8f11fa52ec" -uuid = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" -version = "0.13.1" - -[[CodecZlib]] -deps = ["BinaryProvider", "Libdl", "Test", "TranscodingStreams"] -git-tree-sha1 = "36bbf5374c661054d41410dc53ff752972583b9b" -uuid = "944b1d66-785c-5afd-91f1-9de20f533193" -version = "0.5.2" - -[[CommonSubexpressions]] -deps = ["Test"] -git-tree-sha1 = "efdaf19ab11c7889334ca247ff4c9f7c322817b0" -uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" -version = "0.2.0" - -[[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "84aa74986c5b9b898b0d1acaf3258741ee64754f" -uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "2.1.0" - -[[Conda]] -deps = ["Compat", "JSON", "VersionParsing"] -git-tree-sha1 = "b625d802587c2150c279a40a646fba63f9bd8187" -uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" -version = "1.2.0" - -[[DataStructures]] -deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"] -git-tree-sha1 = "ca971f03e146cf144a9e2f2ce59674f5bf0e8038" -uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.15.0" - -[[Dates]] -deps = ["Printf"] -uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" - -[[DelimitedFiles]] -deps = ["Mmap"] -uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" - -[[DiffEqDiffTools]] -deps = ["LinearAlgebra", "Test"] -git-tree-sha1 = "30f82c63cb9d293513b360572e283c19577fcf82" -uuid = "01453d9d-ee7c-5054-8395-0335cb756afa" -version = "0.8.1" - -[[DiffResults]] -deps = ["Compat", "StaticArrays"] -git-tree-sha1 = "34a4a1e8be7bc99bc9c611b895b5baf37a80584c" -uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" -version = "0.0.4" - -[[DiffRules]] -deps = ["Random", "Test"] -git-tree-sha1 = "dc0869fb2f5b23466b32ea799bd82c76480167f7" -uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" -version = "0.0.10" - -[[Distances]] -deps = ["LinearAlgebra", "Printf", "Random", "Statistics", "Test"] -git-tree-sha1 = "a135c7c062023051953141da8437ed74f89d767a" -uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" -version = "0.8.0" - -[[Distributed]] -deps = ["Random", "Serialization", "Sockets"] -uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" - -[[Distributions]] -deps = ["LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"] -git-tree-sha1 = "56a158bc0abe4af5d4027af2275fde484261ca6d" -uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" -version = "0.19.2" - -[[FFTW]] -deps = ["AbstractFFTs", "BinaryProvider", "Compat", "Conda", "Libdl", "LinearAlgebra", "Reexport", "Test"] -git-tree-sha1 = "29cda58afbf62f35b1a094882ad6c745a47b2eaa" -uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" -version = "0.2.4" - -[[FileIO]] -deps = ["Pkg", "Random", "Test"] -git-tree-sha1 = "da32159d4a2e526338506685e280e39ed2f18961" -uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.0.6" - -[[ForwardDiff]] -deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "InteractiveUtils", "LinearAlgebra", "NaNMath", "Random", "SparseArrays", "SpecialFunctions", "StaticArrays", "Test"] -git-tree-sha1 = "4c4d727f1b7e0092134fabfab6396b8945c1ea5b" -uuid = "f6369f11-7733-5829-9624-2563aa707210" -version = "0.10.3" - -[[InteractiveUtils]] -deps = ["Markdown"] -uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" - -[[Interpolations]] -deps = ["AxisAlgorithms", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"] -git-tree-sha1 = "63665619f2b1a791d3c223acd8bc9155464f3dd3" -uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" -version = "0.12.0" - -[[JLD2]] -deps = ["CodecZlib", "DataStructures", "FileIO", "LinearAlgebra", "Mmap", "Printf", "Random", "Test"] -git-tree-sha1 = "3ba90ff93e1d5b9b2103588051c2d349fae54dac" -uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819" -version = "0.1.2" - -[[JSON]] -deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] -git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" -uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.20.0" - -[[KernelDensity]] -deps = ["Distributions", "FFTW", "Interpolations", "Optim", "StatsBase", "Test"] -git-tree-sha1 = "c1048817fe5711f699abc8fabd47b1ac6ba4db04" -uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b" -version = "0.5.1" - -[[LibGit2]] -uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" - -[[Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" - -[[LineSearches]] -deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf", "Test"] -git-tree-sha1 = "54eb90e8dbe745d617c78dee1d6ae95c7f6f5779" -uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255" -version = "7.0.1" - -[[LinearAlgebra]] -deps = ["Libdl"] -uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" - -[[Logging]] -uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" - -[[Markdown]] -deps = ["Base64"] -uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" - -[[Missings]] -deps = ["SparseArrays", "Test"] -git-tree-sha1 = "f0719736664b4358aa9ec173077d4285775f8007" -uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" -version = "0.4.1" - -[[Mmap]] -uuid = "a63ad114-7e13-5084-954f-fe012c677804" - -[[NLSolversBase]] -deps = ["Calculus", "DiffEqDiffTools", "DiffResults", "Distributed", "ForwardDiff", "LinearAlgebra", "Random", "SparseArrays", "Test"] -git-tree-sha1 = "0c6f0e7f2178f78239cfb75310359eed10f2cacb" -uuid = "d41bc354-129a-5804-8e4c-c37616107c6c" -version = "7.3.1" - -[[NaNMath]] -deps = ["Compat"] -git-tree-sha1 = "ce3b85e484a5d4c71dd5316215069311135fa9f2" -uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" -version = "0.3.2" - -[[NearestNeighbors]] -deps = ["Distances", "LinearAlgebra", "Mmap", "StaticArrays", "Test"] -git-tree-sha1 = "f47c5d97cf9a8caefa47e9fa9d99d8fda1a65154" -uuid = "b8a86587-4115-5ab1-83bc-aa920d37bbce" -version = "0.4.3" - -[[OffsetArrays]] -deps = ["DelimitedFiles"] -git-tree-sha1 = "49a6d9b5b3dedec18035e4d97ce77e2b2a182c05" -uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "0.11.0" - -[[Optim]] -deps = ["Calculus", "DiffEqDiffTools", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "Random", "SparseArrays", "StatsBase", "Test"] -git-tree-sha1 = "a626e09c1f7f019b8f3a30a8172c7b82d2f4810b" -uuid = "429524aa-4258-5aef-a3af-852621145aeb" -version = "0.18.1" - -[[OrderedCollections]] -deps = ["Random", "Serialization", "Test"] -git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1" -uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.1.0" - -[[PDMats]] -deps = ["Arpack", "LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"] -git-tree-sha1 = "8b68513175b2dc4023a564cb0e917ce90e74fd69" -uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" -version = "0.9.7" - -[[Parameters]] -deps = ["Markdown", "OrderedCollections", "REPL", "Test"] -git-tree-sha1 = "70bdbfb2bceabb15345c0b54be4544813b3444e4" -uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a" -version = "0.10.3" - -[[Pkg]] -deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" - -[[PositiveFactorizations]] -deps = ["LinearAlgebra", "Test"] -git-tree-sha1 = "86ae7329c4b5c266acf5c7c524a972300d991e1c" -uuid = "85a6dd25-e78a-55b7-8502-1745935b8125" -version = "0.2.1" - -[[Printf]] -deps = ["Unicode"] -uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" - -[[QuadGK]] -deps = ["DataStructures", "LinearAlgebra", "Test"] -git-tree-sha1 = "3ce467a8e76c6030d4c3786e7d3a73442017cdc0" -uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" -version = "2.0.3" - -[[REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" - -[[Random]] -deps = ["Serialization"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" - -[[Ratios]] -deps = ["Compat"] -git-tree-sha1 = "cdbbe0f350581296f3a2e3e7a91b214121934407" -uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439" -version = "0.3.1" - -[[RecipesBase]] -deps = ["Random", "Test"] -git-tree-sha1 = "0b3cb370ee4dc00f47f1193101600949f3dcf884" -uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "0.6.0" - -[[Reexport]] -deps = ["Pkg"] -git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" -uuid = "189a3867-3050-52da-a836-e630ba90ab69" -version = "0.2.0" - -[[Rmath]] -deps = ["BinaryProvider", "Libdl", "Random", "Statistics", "Test"] -git-tree-sha1 = "9a6c758cdf73036c3239b0afbea790def1dabff9" -uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa" -version = "0.5.0" - -[[SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" - -[[Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[SharedArrays]] -deps = ["Distributed", "Mmap", "Random", "Serialization"] -uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" - -[[Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" - -[[SortingAlgorithms]] -deps = ["DataStructures", "Random", "Test"] -git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd" -uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "0.3.1" - -[[SparseArrays]] -deps = ["LinearAlgebra", "Random"] -uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" - -[[SpecialFunctions]] -deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"] -git-tree-sha1 = "0b45dc2e45ed77f445617b99ff2adf0f5b0f23ea" -uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "0.7.2" - -[[StaticArrays]] -deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"] -git-tree-sha1 = "3841b39ed5f047db1162627bf5f80a9cd3e39ae2" -uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "0.10.3" - -[[Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] -uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" - -[[StatsBase]] -deps = ["DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics"] -git-tree-sha1 = "8a0f4b09c7426478ab677245ab2b0b68552143c7" -uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.30.0" - -[[StatsFuns]] -deps = ["Rmath", "SpecialFunctions", "Test"] -git-tree-sha1 = "b3a4e86aa13c732b8a8c0ba0c3d3264f55e6bb3e" -uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" -version = "0.8.0" - -[[SuiteSparse]] -deps = ["Libdl", "LinearAlgebra", "SparseArrays"] -uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" - -[[Test]] -deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] -uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[[TranscodingStreams]] -deps = ["Random", "Test"] -git-tree-sha1 = "a25d8e5a28c3b1b06d3859f30757d43106791919" -uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.9.4" - -[[URIParser]] -deps = ["Test", "Unicode"] -git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" -uuid = "30578b45-9adc-5946-b283-645ec420af67" -version = "0.4.0" - -[[UUIDs]] -deps = ["Random", "SHA"] -uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" - -[[Unicode]] -uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" - -[[VersionParsing]] -deps = ["Compat"] -git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" -uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" -version = "1.1.3" - -[[WoodburyMatrices]] -deps = ["LinearAlgebra", "Random", "SparseArrays", "Test"] -git-tree-sha1 = "21772c33b447757ec7d3e61fcdfb9ea5c47eedcf" -uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6" -version = "0.4.1" diff --git a/NEWS.md b/NEWS.md index 95a2799..cffb206 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # Kpax3.jl Release Notes +## Changes from v0.5.1 to v0.5.2 + +* Upgrade to Julia 1.2 + ## Changes from v0.5.0 to v0.5.1 * Upgrade to Julia 1.1 diff --git a/Project.toml b/Project.toml index 49a407d..ce3ea27 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Kpax3" uuid = "ad72c4b6-2990-538c-bd38-e122d63d24d9" authors = ["Alberto Pessia "] -version = "0.5.1" +version = "0.5.2" [deps] Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" @@ -16,7 +16,8 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" [compat] -julia = "1.1" +julia = "1" +SpecialFunctions = "0.8" [extras] Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" diff --git a/src/Kpax3.jl b/src/Kpax3.jl index cb03eb8..20c5add 100644 --- a/src/Kpax3.jl +++ b/src/Kpax3.jl @@ -4,15 +4,15 @@ module Kpax3 ################# # Load packages # ################# - import Clustering - import DelimitedFiles - import Distances - import FileIO - import KernelDensity - import Printf - import RecipesBase - import SpecialFunctions - import StatsBase + using Clustering + using DelimitedFiles + using Distances + using FileIO + using KernelDensity + using Printf + using RecipesBase + using SpecialFunctions + using StatsBase #################### # Export functions # diff --git a/src/model/likelihoods/marginal_likelihood.jl b/src/model/likelihoods/marginal_likelihood.jl index 4e0d390..8f8b972 100644 --- a/src/model/likelihoods/marginal_likelihood.jl +++ b/src/model/likelihoods/marginal_likelihood.jl @@ -4,14 +4,15 @@ function logmarglik(y::Vector{Float64}, n::Real, α::Vector{Float64}, β::Vector{Float64}) - SpecialFunctions.lbeta.(α .+ y, β .- y .+ n) .- SpecialFunctions.lbeta.(α, β) + SpecialFunctions.logbeta.(α .+ y, β .- y .+ n) .- + SpecialFunctions.logbeta.(α, β) end function logmarglik(y::Real, n::Real, α::Real, β::Real) - SpecialFunctions.lbeta(α + y, β + n - y) - SpecialFunctions.lbeta(α, β) + SpecialFunctions.logbeta(α + y, β + n - y) - SpecialFunctions.logbeta(α, β) end function logcondmarglik(x::Vector{UInt8}, diff --git a/src/model/partitionrows/ewenspitman/densities.jl b/src/model/partitionrows/ewenspitman/densities.jl index 46d088f..d05023f 100644 --- a/src/model/partitionrows/ewenspitman/densities.jl +++ b/src/model/partitionrows/ewenspitman/densities.jl @@ -16,15 +16,15 @@ function logdPriorRow(p::Vector{Int}, end logp = (k - 1) * log(ep.α) + - SpecialFunctions.lgamma(ep.θ / ep.α + k) - - SpecialFunctions.lgamma(ep.θ / ep.α + 1) + - SpecialFunctions.lgamma(ep.θ + 1) - - SpecialFunctions.lgamma(ep.θ + n) - - k * SpecialFunctions.lgamma(1 - ep.α) + SpecialFunctions.loggamma(ep.θ / ep.α + k) - + SpecialFunctions.loggamma(ep.θ / ep.α + 1) + + SpecialFunctions.loggamma(ep.θ + 1) - + SpecialFunctions.loggamma(ep.θ + n) - + k * SpecialFunctions.loggamma(1 - ep.α) for a in 1:n if m[a] > 0 - logp += SpecialFunctions.lgamma(m[a] - ep.α) + logp += SpecialFunctions.loggamma(m[a] - ep.α) end end @@ -36,15 +36,15 @@ function logdPriorRow(n::Int, m::Vector{Int}, ep::EwensPitmanPAUT) logp = (k - 1) * log(ep.α) + - SpecialFunctions.lgamma(ep.θ / ep.α + k) - - SpecialFunctions.lgamma(ep.θ / ep.α + 1) + - SpecialFunctions.lgamma(ep.θ + 1) - - SpecialFunctions.lgamma(ep.θ + n) - - k * SpecialFunctions.lgamma(1 - ep.α) + SpecialFunctions.loggamma(ep.θ / ep.α + k) - + SpecialFunctions.loggamma(ep.θ / ep.α + 1) + + SpecialFunctions.loggamma(ep.θ + 1) - + SpecialFunctions.loggamma(ep.θ + n) - + k * SpecialFunctions.loggamma(1 - ep.α) for a in 1:length(m) if m[a] > 0 - logp += SpecialFunctions.lgamma(m[a] - ep.α) + logp += SpecialFunctions.loggamma(m[a] - ep.α) end end @@ -67,13 +67,13 @@ function logdPriorRow(p::Vector{Int}, end logp = (k - 1) * log(ep.α) + - SpecialFunctions.lgamma(k) - - SpecialFunctions.lgamma(n) - - k * SpecialFunctions.lgamma(1 - ep.α) + SpecialFunctions.loggamma(k) - + SpecialFunctions.loggamma(n) - + k * SpecialFunctions.loggamma(1 - ep.α) for a in 1:n if m[a] > 0 - logp += SpecialFunctions.lgamma(m[a] - ep.α) + logp += SpecialFunctions.loggamma(m[a] - ep.α) end end @@ -85,13 +85,13 @@ function logdPriorRow(n::Int, m::Vector{Int}, ep::EwensPitmanPAZT) logp = (k - 1) * log(ep.α) + - SpecialFunctions.lgamma(k) - - SpecialFunctions.lgamma(n) - - k * SpecialFunctions.lgamma(1 - ep.α) + SpecialFunctions.loggamma(k) - + SpecialFunctions.loggamma(n) - + k * SpecialFunctions.loggamma(1 - ep.α) for a in 1:length(m) if m[a] > 0 - logp += SpecialFunctions.lgamma(m[a] - ep.α) + logp += SpecialFunctions.loggamma(m[a] - ep.α) end end @@ -114,12 +114,12 @@ function logdPriorRow(p::Vector{Int}, end logp = k * log(ep.θ) + - SpecialFunctions.lgamma(ep.θ) - - SpecialFunctions.lgamma(ep.θ + n) + SpecialFunctions.loggamma(ep.θ) - + SpecialFunctions.loggamma(ep.θ + n) for a in 1:n if m[a] > 0 - logp += SpecialFunctions.lgamma(m[a]) + logp += SpecialFunctions.loggamma(m[a]) end end @@ -131,12 +131,12 @@ function logdPriorRow(n::Int, m::Vector{Int}, ep::EwensPitmanZAPT) logp = k * log(ep.θ) + - SpecialFunctions.lgamma(ep.θ) - - SpecialFunctions.lgamma(ep.θ + n) + SpecialFunctions.loggamma(ep.θ) - + SpecialFunctions.loggamma(ep.θ + n) for a in 1:length(m) if m[a] > 0 - logp += SpecialFunctions.lgamma(m[a]) + logp += SpecialFunctions.loggamma(m[a]) end end @@ -159,8 +159,8 @@ function logdPriorRow(p::Vector{Int}, end log(prod((1:(k - 1)) .- ep.L) * ep.α^(k - 1) * - exp(sum(SpecialFunctions.lgamma.(m[m .> 0] .- ep.α)) - - k * SpecialFunctions.lgamma(1 - ep.α)) / + exp(sum(SpecialFunctions.loggamma.(m[m .> 0] .- ep.α)) - + k * SpecialFunctions.loggamma(1 - ep.α)) / prod((1:(n - 1)) .- ep.α * ep.L)) end @@ -169,8 +169,8 @@ function logdPriorRow(n::Int, m::Vector{Int}, ep::EwensPitmanNAPT) log(prod((1:(k - 1)) .- ep.L) * ep.α^(k - 1) * - exp(sum(SpecialFunctions.lgamma.(m[m .> 0] .- ep.α)) - - k * SpecialFunctions.lgamma(1 - ep.α)) / + exp(sum(SpecialFunctions.loggamma.(m[m .> 0] .- ep.α)) - + k * SpecialFunctions.loggamma(1 - ep.α)) / prod((1:(n - 1)) .- ep.α * ep.L)) end diff --git a/src/model/partitionrows/ewenspitman/mcmc.jl b/src/model/partitionrows/ewenspitman/mcmc.jl index affa115..23e2c0b 100644 --- a/src/model/partitionrows/ewenspitman/mcmc.jl +++ b/src/model/partitionrows/ewenspitman/mcmc.jl @@ -47,33 +47,33 @@ end function logratiopriorrowmerge!(k::Real, ep::EwensPitmanPAUT, support::MCMCSupport) - support.lograR = SpecialFunctions.lgamma(1 - ep.α) + - SpecialFunctions.lgamma(support.vi + support.vj - ep.α) - + support.lograR = SpecialFunctions.loggamma(1 - ep.α) + + SpecialFunctions.loggamma(support.vi + support.vj - ep.α) - log(ep.θ + k * ep.α) - - SpecialFunctions.lgamma(support.vi - ep.α) - - SpecialFunctions.lgamma(support.vj - ep.α) + SpecialFunctions.loggamma(support.vi - ep.α) - + SpecialFunctions.loggamma(support.vj - ep.α) nothing end function logratiopriorrowmerge!(k::Real, ep::EwensPitmanPAZT, support::MCMCSupport) - support.lograR = SpecialFunctions.lgamma(1 - ep.α) + - SpecialFunctions.lgamma(support.vi + support.vj - ep.α) - + support.lograR = SpecialFunctions.loggamma(1 - ep.α) + + SpecialFunctions.loggamma(support.vi + support.vj - ep.α) - log(k) - log(ep.α) - - SpecialFunctions.lgamma(support.vi - ep.α) - - SpecialFunctions.lgamma(support.vj - ep.α) + SpecialFunctions.loggamma(support.vi - ep.α) - + SpecialFunctions.loggamma(support.vj - ep.α) nothing end function logratiopriorrowmerge!(k::Real, ep::EwensPitmanZAPT, support::MCMCSupport) - support.lograR = SpecialFunctions.lgamma(support.vi + support.vj) - + support.lograR = SpecialFunctions.loggamma(support.vi + support.vj) - log(ep.θ) - - SpecialFunctions.lgamma(support.vi) - - SpecialFunctions.lgamma(support.vj) + SpecialFunctions.loggamma(support.vi) - + SpecialFunctions.loggamma(support.vj) nothing end @@ -82,10 +82,10 @@ function logratiopriorrowmerge!(k::Real, support::MCMCSupport) support.lograR = - log( (k - ep.L) * ep.α * - exp(SpecialFunctions.lgamma(support.vi - ep.α) + - SpecialFunctions.lgamma(support.vj - ep.α) - - SpecialFunctions.lgamma(1 - ep.α) - - SpecialFunctions.lgamma(support.vi + support.vj - ep.α)) + exp(SpecialFunctions.loggamma(support.vi - ep.α) + + SpecialFunctions.loggamma(support.vj - ep.α) - + SpecialFunctions.loggamma(1 - ep.α) - + SpecialFunctions.loggamma(support.vi + support.vj - ep.α)) ) nothing @@ -95,10 +95,10 @@ function logratiopriorrowsplit!(k::Real, ep::EwensPitmanPAUT, support::MCMCSupport) support.lograR = log(ep.θ + (k - 1) * ep.α) - - SpecialFunctions.lgamma(1 - ep.α) + - SpecialFunctions.lgamma(support.vi - ep.α) + - SpecialFunctions.lgamma(support.vj - ep.α) - - SpecialFunctions.lgamma(support.vi + support.vj - ep.α) + SpecialFunctions.loggamma(1 - ep.α) + + SpecialFunctions.loggamma(support.vi - ep.α) + + SpecialFunctions.loggamma(support.vj - ep.α) - + SpecialFunctions.loggamma(support.vi + support.vj - ep.α) nothing end @@ -107,10 +107,10 @@ function logratiopriorrowsplit!(k::Real, support::MCMCSupport) support.lograR = log(k - 1) + log(ep.α) - - SpecialFunctions.lgamma(1 - ep.α) + - SpecialFunctions.lgamma(support.vi - ep.α) + - SpecialFunctions.lgamma(support.vj - ep.α) - - SpecialFunctions.lgamma(support.vi + support.vj - ep.α) + SpecialFunctions.loggamma(1 - ep.α) + + SpecialFunctions.loggamma(support.vi - ep.α) + + SpecialFunctions.loggamma(support.vj - ep.α) - + SpecialFunctions.loggamma(support.vi + support.vj - ep.α) nothing end @@ -118,9 +118,9 @@ function logratiopriorrowsplit!(k::Real, ep::EwensPitmanZAPT, support::MCMCSupport) support.lograR = log(ep.θ) + - SpecialFunctions.lgamma(support.vi) + - SpecialFunctions.lgamma(support.vj) - - SpecialFunctions.lgamma(support.vi + support.vj) + SpecialFunctions.loggamma(support.vi) + + SpecialFunctions.loggamma(support.vj) - + SpecialFunctions.loggamma(support.vi + support.vj) nothing end @@ -129,10 +129,10 @@ function logratiopriorrowsplit!(k::Real, support::MCMCSupport) support.lograR = log( (k - 1 - ep.L) * ep.α * - exp(SpecialFunctions.lgamma(support.vi - ep.α) + - SpecialFunctions.lgamma(support.vj - ep.α) - - SpecialFunctions.lgamma(1 - ep.α) - - SpecialFunctions.lgamma(support.vi + support.vj - ep.α)) + exp(SpecialFunctions.loggamma(support.vi - ep.α) + + SpecialFunctions.loggamma(support.vj - ep.α) - + SpecialFunctions.loggamma(1 - ep.α) - + SpecialFunctions.loggamma(support.vi + support.vj - ep.α)) ) nothing @@ -197,8 +197,8 @@ function logratiopriorrowmerge(k::Real, ep::EwensPitmanNAPT) - log( (k - ep.L) * ep.α * - exp(SpecialFunctions.lgamma(vj - ep.α) - - SpecialFunctions.lgamma(vj + 1 - ep.α))) + exp(SpecialFunctions.loggamma(vj - ep.α) - + SpecialFunctions.loggamma(vj + 1 - ep.α))) end function logratiopriorrowmove(vi::Real, @@ -212,6 +212,6 @@ function logratiopriorrowsplit(k::Real, ep::EwensPitmanNAPT) log( (k - 1 - ep.L) * ep.α * - exp(SpecialFunctions.lgamma(vi - 1 - ep.α) - - SpecialFunctions.lgamma(vi - ep.α))) + exp(SpecialFunctions.loggamma(vi - 1 - ep.α) - + SpecialFunctions.loggamma(vi - ep.α))) end diff --git a/src/optimizer/local_mode.jl b/src/optimizer/local_mode.jl index f1a3f6c..0d0c82a 100644 --- a/src/optimizer/local_mode.jl +++ b/src/optimizer/local_mode.jl @@ -24,34 +24,34 @@ function computelocalmode!(v::Vector{Int}, lγ[2] = priorC.logγ[2] lγ[3] = priorC.logγ[3] - tmp1[1] = SpecialFunctions.lbeta(priorC.A[1, b], priorC.B[1, b]) - tmp1[2] = SpecialFunctions.lbeta(priorC.A[2, b], priorC.B[2, b]) - tmp1[3] = SpecialFunctions.lbeta(priorC.A[3, b], priorC.B[3, b]) - + tmp1[1] = SpecialFunctions.logbeta(priorC.A[1, b], priorC.B[1, b]) + tmp1[2] = SpecialFunctions.logbeta(priorC.A[2, b], priorC.B[2, b]) + tmp1[3] = SpecialFunctions.logbeta(priorC.A[3, b], priorC.B[3, b]) - priorC.logω[k][1] - tmp1[4] = SpecialFunctions.lbeta(priorC.A[4, b], priorC.B[4, b]) - + tmp1[4] = SpecialFunctions.logbeta(priorC.A[4, b], priorC.B[4, b]) - priorC.logω[k][2] for l in 1:k g = cl[l] # noise - lγ[1] += SpecialFunctions.lbeta(priorC.A[1, b] + n1s[g, b], - priorC.B[1, b] + v[g] - n1s[g, b]) - + lγ[1] += SpecialFunctions.logbeta(priorC.A[1, b] + n1s[g, b], + priorC.B[1, b] + v[g] - n1s[g, b]) - tmp1[1] # weak signal - lγ[2] += SpecialFunctions.lbeta(priorC.A[2, b] + n1s[g, b], - priorC.B[2, b] + v[g] - n1s[g, b]) - + lγ[2] += SpecialFunctions.logbeta(priorC.A[2, b] + n1s[g, b], + priorC.B[2, b] + v[g] - n1s[g, b]) - tmp1[2] # strong signal but not characteristic - tmp2[1, l] = SpecialFunctions.lbeta(priorC.A[3, b] + n1s[g, b], - priorC.B[3, b] + v[g] - n1s[g, b]) - + tmp2[1, l] = SpecialFunctions.logbeta(priorC.A[3, b] + n1s[g, b], + priorC.B[3, b] + v[g] - n1s[g, b]) - tmp1[3] # strong signal and characteristic - tmp2[2, l] = SpecialFunctions.lbeta(priorC.A[4, b] + n1s[g, b], - priorC.B[4, b] + v[g] - n1s[g, b]) - + tmp2[2, l] = SpecialFunctions.logbeta(priorC.A[4, b] + n1s[g, b], + priorC.B[4, b] + v[g] - n1s[g, b]) - tmp1[4] if tmp2[1, l] >= tmp2[2, l] @@ -125,35 +125,35 @@ function computelocalmode!(state::State, lγ[2] = priorC.logγ[2] lγ[3] = priorC.logγ[3] - tmp1[1] = SpecialFunctions.lbeta(priorC.A[1, b], priorC.B[1, b]) - tmp1[2] = SpecialFunctions.lbeta(priorC.A[2, b], priorC.B[2, b]) - tmp1[3] = SpecialFunctions.lbeta(priorC.A[3, b], priorC.B[3, b]) - + tmp1[1] = SpecialFunctions.logbeta(priorC.A[1, b], priorC.B[1, b]) + tmp1[2] = SpecialFunctions.logbeta(priorC.A[2, b], priorC.B[2, b]) + tmp1[3] = SpecialFunctions.logbeta(priorC.A[3, b], priorC.B[3, b]) - priorC.logω[k][1] - tmp1[4] = SpecialFunctions.lbeta(priorC.A[4, b], priorC.B[4, b]) - + tmp1[4] = SpecialFunctions.logbeta(priorC.A[4, b], priorC.B[4, b]) - priorC.logω[k][2] for l in 1:k g = state.cl[l] # noise - lγ[1] += SpecialFunctions.lbeta(priorC.A[1, b] + state.n1s[g, b], - priorC.B[1, b] + state.v[g] - - state.n1s[g, b]) - tmp1[1] + lγ[1] += SpecialFunctions.logbeta(priorC.A[1, b] + state.n1s[g, b], + priorC.B[1, b] + state.v[g] - + state.n1s[g, b]) - tmp1[1] # weak signal - lγ[2] += SpecialFunctions.lbeta(priorC.A[2, b] + state.n1s[g, b], - priorC.B[2, b] + state.v[g] - - state.n1s[g, b]) - tmp1[2] + lγ[2] += SpecialFunctions.logbeta(priorC.A[2, b] + state.n1s[g, b], + priorC.B[2, b] + state.v[g] - + state.n1s[g, b]) - tmp1[2] # strong signal but not characteristic - tmp2[1, l] = SpecialFunctions.lbeta(priorC.A[3, b] + state.n1s[g, b], - priorC.B[3, b] + state.v[g] - - state.n1s[g, b]) - tmp1[3] + tmp2[1, l] = SpecialFunctions.logbeta(priorC.A[3, b] + state.n1s[g, b], + priorC.B[3, b] + state.v[g] - + state.n1s[g, b]) - tmp1[3] # strong signal and characteristic - tmp2[2, l] = SpecialFunctions.lbeta(priorC.A[4, b] + state.n1s[g, b], - priorC.B[4, b] + state.v[g] - - state.n1s[g, b]) - tmp1[4] + tmp2[2, l] = SpecialFunctions.logbeta(priorC.A[4, b] + state.n1s[g, b], + priorC.B[4, b] + state.v[g] - + state.n1s[g, b]) - tmp1[4] if tmp2[1, l] >= tmp2[2, l] tmp3 = log1p(exp(tmp2[2, l] - tmp2[1, l])) diff --git a/test/model/likelihoods.jl b/test/model/likelihoods.jl index 5570aeb..b1ea270 100644 --- a/test/model/likelihoods.jl +++ b/test/model/likelihoods.jl @@ -3,7 +3,7 @@ function test_likelihoods_marginal() for (α, β) in ([0.1, 0.1], [0.5, 0.5], [1.0, 1.0], [10.0, 10.0], [100.0, 100.0], [0.2, 0.1], [1.0, 0.5], [2.0, 1.0], [20.0, 10.0], [200.0, 100.0], [0.1, 0.2], [0.5, 1.0], [1.0, 2.0], [10.0, 20.0], [100.0, 200.0]) for (n, y) in ([1.0, 0.0], [1.0, 1.0], [5.0, 0.0], [5.0, 1.0], [5.0, 3.0], [5.0, 5.0], [10.0, 0.0], [10.0, 1.0], [10.0, 5.0], [10.0, 10.0], [100.0, 0.0], [100.0, 1.0], [100.0, 10.0], [100.0, 100.0]) - logp = SpecialFunctions.lgamma(α + y) + SpecialFunctions.lgamma(β + n - y) - SpecialFunctions.lgamma(α + β + n) + SpecialFunctions.lgamma(α + β) - SpecialFunctions.lgamma(α) - SpecialFunctions.lgamma(β) + logp = SpecialFunctions.loggamma(α + y) + SpecialFunctions.loggamma(β + n - y) - SpecialFunctions.loggamma(α + β + n) + SpecialFunctions.loggamma(α + β) - SpecialFunctions.loggamma(α) - SpecialFunctions.loggamma(β) logcp0 = log(β + n - y) - log(α + β + n) logcp1 = log(α + y) - log(α + β + n) @@ -39,7 +39,7 @@ function test_likelihoods_marginal() qx = Kpax3.condmarglik([fill(0x01, n1s); fill(0x00, m - n1s)], y, n, a, b) logqx = Kpax3.logcondmarglik([fill(0x01, n1s); fill(0x00, m - n1s)], y, n, a, b) - logp = SpecialFunctions.lgamma.(a .+ y) .+ SpecialFunctions.lgamma.(b .+ n .- y) .- SpecialFunctions.lgamma.(a .+ b .+ n) .+ SpecialFunctions.lgamma.(a .+ b) .- SpecialFunctions.lgamma.(a) .- SpecialFunctions.lgamma.(b) + logp = SpecialFunctions.loggamma.(a .+ y) .+ SpecialFunctions.loggamma.(b .+ n .- y) .- SpecialFunctions.loggamma.(a .+ b .+ n) .+ SpecialFunctions.loggamma.(a .+ b) .- SpecialFunctions.loggamma.(a) .- SpecialFunctions.loggamma.(b) logcp0 = log.(b .+ n .- y) .- log.(a .+ b .+ n) logcp1 = log.(a .+ y) .- log.(a .+ b .+ n) diff --git a/test/runtests.jl b/test/runtests.jl index f4f126a..68ea84e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,9 +15,7 @@ using Test gr(size=(800, 600)) -cd(dirname(@__FILE__)) - -import Kpax3 +using Kpax3 ε = 1.0e-13 Random.seed!(1427371200)