Commit fabaca28 authored by Alberto Ramos's avatar Alberto Ramos

Adds support to tag ensembles with a String.

- Native BDIO format also adds this option
parent 6cd322d4
......@@ -8,18 +8,18 @@ version = "0.5.0"
[[Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "0fac443759fa829ed8066db6cf1077d888bb6573"
git-tree-sha1 = "95f8bda0555209f122bc796b0382ea4a3a121720"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "2.0.2"
version = "2.1.0"
[[ArgCheck]]
git-tree-sha1 = "59c256cf71c3982484ae4486ee86a3d7da891dea"
git-tree-sha1 = "dedbbb2ddb876f899585c4ec4433265e3017215a"
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
version = "2.0.0"
version = "2.1.0"
[[BDIO]]
deps = ["Documenter", "Nettle"]
git-tree-sha1 = "6097f62fdbf858aa97d928005f2bc511e06018bc"
git-tree-sha1 = "31aa5298af4936ad33dd39f43ef0c3f7c45fb197"
repo-rev = "master"
repo-url = "https://gitlab.ift.uam-csic.es/alberto/bdio.jl.git"
uuid = "375f315e-f2c4-11e9-2ef9-134f02f79e27"
......@@ -42,9 +42,9 @@ version = "0.5.10"
[[Bzip2_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "3663bfffede2ef41358b6fc2e1d8a6d50b3c3904"
git-tree-sha1 = "03a44490020826950c68005cafb336e5ba08b7e8"
uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
version = "1.0.6+2"
version = "1.0.6+4"
[[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"]
......@@ -54,15 +54,15 @@ version = "3.9.0"
[[ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "6e7aa35d0294f647bb9c985ccc34d4f5d371a533"
git-tree-sha1 = "4bffea7ed1a9f0f3d1a131bbcd4b925548d75288"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.10.6"
version = "0.10.9"
[[Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Reexport"]
git-tree-sha1 = "5639e44833cfcf78c6a73fbceb4da75611d312cd"
git-tree-sha1 = "008d6bc68dea6beb6303fdc37188cb557391ebf2"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.3"
version = "0.12.4"
[[CommonSubexpressions]]
deps = ["Test"]
......@@ -72,9 +72,9 @@ version = "0.2.1"
[[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 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb"
git-tree-sha1 = "b0b7e8a0d054fada22b64095b46469627a138943"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "2.2.0"
version = "2.2.1"
[[CompilerSupportLibraries_jll]]
deps = ["Libdl", "Pkg"]
......@@ -84,9 +84,9 @@ version = "0.3.3+0"
[[Contour]]
deps = ["StaticArrays"]
git-tree-sha1 = "0b17db36e7e03f8437e0d1f55aea3e4a60c74353"
git-tree-sha1 = "d05a3a25b762720d40246d5bedf518c9c2614ef5"
uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
version = "0.5.3"
version = "0.5.5"
[[DataAPI]]
git-tree-sha1 = "176e23402d80e7743fc26c19c681bfb11246af32"
......@@ -95,9 +95,9 @@ version = "1.3.0"
[[DataStructures]]
deps = ["InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "edad9434967fdc0a2631a65d902228400642120c"
git-tree-sha1 = "88d48e133e6d3dd68183309877eac74393daa7eb"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.17.19"
version = "0.17.20"
[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
......@@ -136,15 +136,15 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "c5714d9bcdba66389612dc4c47ed827c64112997"
git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.2"
version = "0.8.3"
[[Documenter]]
deps = ["Base64", "Dates", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "f3464968c65fc78846dad1c038c474a2c39bbb23"
git-tree-sha1 = "fb1ff838470573adc15c71ba79f8d31328f035da"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.25.0"
version = "0.25.2"
[[FFMPEG]]
deps = ["FFMPEG_jll"]
......@@ -154,9 +154,9 @@ version = "0.3.0"
[[FFMPEG_jll]]
deps = ["Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "LAME_jll", "LibVPX_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "Pkg", "Zlib_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"]
git-tree-sha1 = "0fa07f43e5609ea54848b82b4bb330b250e9645b"
git-tree-sha1 = "13a934b9e74a8722bf1786c989de346a9602e695"
uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
version = "4.1.0+3"
version = "4.3.1+2"
[[FFTW]]
deps = ["AbstractFFTs", "FFTW_jll", "IntelOpenMP_jll", "Libdl", "LinearAlgebra", "MKL_jll", "Reexport"]
......@@ -177,9 +177,10 @@ uuid = "442a2c76-b920-505d-bb47-c5924d526838"
version = "0.4.2"
[[FixedPointNumbers]]
git-tree-sha1 = "8fb797c37a3b7ced4327a05ac4ca0dd6a4f1ba92"
deps = ["Statistics"]
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
version = "0.8.1"
version = "0.8.4"
[[ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "NaNMath", "Random", "SpecialFunctions", "StaticArrays"]
......@@ -189,15 +190,15 @@ version = "0.10.10"
[[FreeType2_jll]]
deps = ["Bzip2_jll", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "7d900f32a3788d4eacac2bfa3bf5c770179c8afd"
git-tree-sha1 = "720eee04e3b496c15e5e2269669c2532fb5005c0"
uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7"
version = "2.10.1+2"
version = "2.10.1+4"
[[FriBidi_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "2f56bee16bd0151de7b6a1eeea2ced190a2ad8d4"
git-tree-sha1 = "cfc3485a0a968263c789e314fca5d66daf75ed6c"
uuid = "559328eb-81f9-559d-9380-de523a88c83c"
version = "1.0.5+3"
version = "1.0.5+5"
[[GR]]
deps = ["Base64", "DelimitedFiles", "HTTP", "JSON", "LinearAlgebra", "Printf", "Random", "Serialization", "Sockets", "Test", "UUIDs"]
......@@ -219,9 +220,9 @@ version = "0.8.3"
[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"]
git-tree-sha1 = "eca61b35cdd8cd2fcc5eec1eda766424a995b02f"
git-tree-sha1 = "c7ec02c4c6a039a98a15f955462cd7aea5df4508"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.8.16"
version = "0.8.19"
[[IniFile]]
deps = ["Test"]
......@@ -251,15 +252,15 @@ version = "1.0.0"
[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.0"
version = "0.21.1"
[[LAME_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "221cc8998b9060677448cbb6375f00032554c4fd"
git-tree-sha1 = "a7999edc634307964d5651265ebf7c2e14b4ef91"
uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d"
version = "3.100.0+1"
version = "3.100.0+2"
[[LaTeXStrings]]
git-tree-sha1 = "de44b395389b84fd681394d4e8d39ef14e3a2ea8"
......@@ -272,9 +273,9 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[LibVPX_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "e3549ca9bf35feb9d9d954f4c6a9032e92f46e7c"
git-tree-sha1 = "e02378f5707d0f94af22b99e4aba798e20368f6e"
uuid = "dd192d2f-8180-539f-9fb4-cc70b1dcf69a"
version = "1.8.1+1"
version = "1.9.0+0"
[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
......@@ -288,9 +289,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[MKL_jll]]
deps = ["IntelOpenMP_jll", "Libdl", "Pkg"]
git-tree-sha1 = "0ce9a7fa68c70cf83c49d05d2c04d91b47404b08"
git-tree-sha1 = "eb540ede3aabb8284cb482aa41d00d6ca850b1f8"
uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
version = "2020.1.216+0"
version = "2020.2.254+0"
[[MacroTools]]
deps = ["Markdown", "Random"]
......@@ -310,9 +311,9 @@ version = "1.0.2"
[[MbedTLS_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "a0cb0d489819fa7ea5f9fa84c7e7eba19d8073af"
git-tree-sha1 = "c0b1286883cac4e2b617539de41111e0776d02e8"
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.16.6+1"
version = "2.16.8+0"
[[Measures]]
git-tree-sha1 = "e498ddeee6f9fdb4551ce855a46f54dbd900245f"
......@@ -321,17 +322,17 @@ version = "0.3.1"
[[Missings]]
deps = ["DataAPI"]
git-tree-sha1 = "de0a5ce9e5289f27df672ffabef4d1e5861247d5"
git-tree-sha1 = "ed61674a0864832495ffe0a7e889c0da76b0f4c8"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "0.4.3"
version = "0.4.4"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[NaNMath]]
git-tree-sha1 = "928b8ca9b2791081dc71a51c55347c27c618760f"
git-tree-sha1 = "c84c576296d0e2fbb3fc134d3e09086b3ea617cd"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.3"
version = "0.3.4"
[[Nettle]]
deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"]
......@@ -341,15 +342,15 @@ version = "0.4.0"
[[Ogg_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "59cf7a95bf5ac39feac80b796e0f39f9d69dc887"
git-tree-sha1 = "4c3275cda1ba99d1244d0b82a9d0ca871c3cf66b"
uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051"
version = "1.3.4+0"
version = "1.3.4+1"
[[OpenSSL_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "7aaaded15bf393b5f34c2aad5b765c18d26cb495"
git-tree-sha1 = "997359379418d233767f926ea0c43f0e731735c0"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "1.1.1+4"
version = "1.1.1+5"
[[OpenSpecFun_jll]]
deps = ["CompilerSupportLibraries_jll", "Libdl", "Pkg"]
......@@ -359,14 +360,14 @@ version = "0.5.3+3"
[[Opus_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "002c18f222a542907e16c83c64a1338992da7e2c"
git-tree-sha1 = "cc90a125aa70dbb069adbda2b913b02cf2c5f6fe"
uuid = "91d4177d-7536-5919-b921-800302f37372"
version = "1.3.1+1"
version = "1.3.1+2"
[[OrderedCollections]]
git-tree-sha1 = "293b70ac1780f9584c89268a6e2a560d938a7065"
git-tree-sha1 = "16c08bf5dba06609fe45e30860092d6fa41fde7b"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.3.0"
version = "1.3.1"
[[PGFPlotsX]]
deps = ["ArgCheck", "DataStructures", "Dates", "DefaultApplication", "DocStringExtensions", "MacroTools", "Parameters", "Requires", "StatsBase"]
......@@ -382,9 +383,9 @@ version = "0.12.1"
[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "20ef902ea02f7000756a4bc19f7b9c24867c6211"
git-tree-sha1 = "8077624b3c450b15c087944363606a6ba12f925e"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.0.6"
version = "1.0.10"
[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
......@@ -398,9 +399,9 @@ version = "2.0.0"
[[PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "e18e0e51ff07bf92bb7e06dcb9c082a4e125e20c"
git-tree-sha1 = "8d23333aee2e2733a5cd4e1985462df8203f47f7"
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
version = "1.0.5"
version = "1.0.6"
[[Plots]]
deps = ["Base64", "Contour", "Dates", "FFMPEG", "FixedPointNumbers", "GR", "GeometryBasics", "GeometryTypes", "JSON", "LinearAlgebra", "Measures", "NaNMath", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "Requires", "Showoff", "SparseArrays", "Statistics", "StatsBase", "UUIDs"]
......@@ -427,15 +428,15 @@ deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[RecipesBase]]
git-tree-sha1 = "54f8ceb165a0f6d083f0d12cb4996f5367c6edbc"
git-tree-sha1 = "6ee6c35fe69e79e17c455a386c1ccdc66d9f7da4"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.0.1"
version = "1.1.0"
[[RecipesPipeline]]
deps = ["Dates", "PlotUtils", "RecipesBase"]
git-tree-sha1 = "d2a58b8291d1c0abae6a91489973f8a92bf5c04a"
deps = ["Dates", "NaNMath", "PlotUtils", "RecipesBase"]
git-tree-sha1 = "4a325c9bcc2d8e62a8f975b9666d0251d53b63b9"
uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c"
version = "0.1.11"
version = "0.1.13"
[[Reexport]]
deps = ["Pkg"]
......@@ -445,9 +446,9 @@ version = "0.2.0"
[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "d37400976e98018ee840e0ca4f9d20baa231dc6b"
git-tree-sha1 = "2fc2e1ab606a5dca7bbad9036a694553c3a57926"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.0.1"
version = "1.0.3"
[[Roots]]
deps = ["Printf"]
......@@ -492,9 +493,9 @@ version = "0.10.3"
[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "5c06c0aeb81bef54aed4b3f446847905eb6cbda0"
git-tree-sha1 = "016d1e1a00fabc556473b07161da3d39726ded35"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "0.12.3"
version = "0.12.4"
[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
......@@ -502,9 +503,9 @@ uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
[[StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics"]
git-tree-sha1 = "a6102b1f364befdb05746f386b67c6b7e3262c45"
git-tree-sha1 = "19bfcb46245f69ff4013b3df3b977a289852c3a1"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.0"
version = "0.32.2"
[[StructArrays]]
deps = ["Adapt", "DataAPI", "Tables"]
......@@ -520,9 +521,9 @@ version = "1.0.0"
[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "c45dcc27331febabc20d86cb3974ef095257dcf3"
git-tree-sha1 = "b7f762e9820b7fab47544c36f26f54ac59cf8abf"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.0.4"
version = "1.0.5"
[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
......@@ -539,9 +540,9 @@ deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[UnPack]]
git-tree-sha1 = "d4bfa022cd30df012700cf380af2141961bb3bfb"
git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b"
uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
version = "1.0.1"
version = "1.0.2"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
......@@ -554,36 +555,36 @@ version = "1.1.0"
[[Zlib_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "622d8b6dc0c7e8029f17127703de9819134d1b71"
git-tree-sha1 = "fdd89e5ab270ea0f2a0174bd9093e557d06d4bfa"
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.11+14"
version = "1.2.11+16"
[[libass_jll]]
deps = ["Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "027a304b2a90de84f690949a21f94e5ae0f92c73"
git-tree-sha1 = "f02d0db58888592e98c5f4953cef620ce9274eee"
uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0"
version = "0.14.0+2"
version = "0.14.0+3"
[[libfdk_aac_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "480c7ed04f68ea3edd4c757f5db5b6a0a4e0bd99"
git-tree-sha1 = "e17b4513993b4413d31cffd1b36a63625ebbc3d3"
uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280"
version = "0.1.6+2"
version = "0.1.6+3"
[[libvorbis_jll]]
deps = ["Libdl", "Ogg_jll", "Pkg"]
git-tree-sha1 = "6a66f65b5275dfa799036c8a3a26616a0a271c4a"
git-tree-sha1 = "8014e1c1033009edcfe820ec25877a9f1862ba4c"
uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a"
version = "1.3.6+4"
version = "1.3.6+5"
[[x264_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "d89346fe63a6465a9f44e958ac0e3d366af90b74"
git-tree-sha1 = "e496625b900df1b02ab0e02fad316b77446616ef"
uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a"
version = "2019.5.25+2"
version = "2020.7.14+1"
[[x265_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "61324ad346b00a6e541896b94201c9426591e43a"
git-tree-sha1 = "ac7d44fa1639a780d0ae79ca1a5a7f4181131825"
uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76"
version = "3.0.0+1"
version = "3.0.0+2"
......@@ -7,7 +7,7 @@ contains variables with uncertainties. In very simple cases this is
just a central value and an error
```@repl gs
using ADerrors
a = uwreal([1.0, 0.1], 1) # 1.0 +/- 0.1
a = uwreal([1.0, 0.1], "Var with error") # 1.0 +/- 0.1
```
But it also supports the case where the uncertainty comes from Monte
Carlo measurements
......@@ -23,10 +23,10 @@ for i in 2:1000
end
end
b = uwreal(x.^2, 200)
c = uwreal(x.^4, 200)
b = uwreal(x.^2, "Random walk ensemble in [-1,1]")
c = uwreal(x.^4, "Random walk ensemble in [-1,1]")
```
Correlations between variables are treated consistently. Each call to `uwreal` contains an ensemble `ID` tag. In the previous examples `a` has been measured on ensemble `ID` 1, while both `b` and `c` have been measured on ensemble `ID` 200. Monte Carlo measurements with the same `ID` tag are assumed to be measured on the same configurations: `b` and `c` above are statistically correlated, while `a` will be uncorrelated with both `b` and `c`.
Correlations between variables are treated consistently. Each call to `uwreal` contains an ensemble `ID` tag. In the previous examples `a` has been measured on ensemble `ID` `Var with error`, while both `b` and `c` have been measured on ensemble `ID` `Random walk ensemble in [-1,1]`. Monte Carlo measurements with the same `ID` tag are assumed to be measured on the same configurations: `b` and `c` above are statistically correlated, while `a` will be uncorrelated with both `b` and `c`.
One can perform operations with `uwreal` variables as if there were normal floats
```@repl gs
......@@ -45,7 +45,7 @@ A call to `uwerr` will apply the ``\Gamma``-method to MC ensembles. `ADerrors.jl
println("Details on variable d: ")
details(d)
```
Here we can see that there are two ensembles contributing to the uncertainty in `d`. We recognize this as `d` being a function of both `a` (measured on ensemble 1), and `b` and `c`, measured on ensemble 200. Most of the error in `d` comes in fact from ensemble 200.
Here we can see that there are two ensembles contributing to the uncertainty in `d`. We recognize this as `d` being a function of both `a` (measured on ensemble `Var with error`), and `b` and `c`, measured on ensemble `Random walk ensemble in [-1,1]`. Most of the error in `d` comes in fact from ensemble `Random walk ensemble in [-1,1]`.
Note that one does not need to use `uwerr` on a variable unless one is interested in the error on that variable. For example, continuing with the previous example
```@repl gs
......@@ -84,8 +84,7 @@ using LsqFit, ADerrors
xdata = range(0, stop=10, length=20);
ydata = Vector{uwreal}(undef, length(xdata));
for i in eachindex(ydata)
# Note that we assign to point i the ID 1000*i
ydata[i] = uwreal([model(xdata[i], [1.0 2.0]) + 0.01*getindex(randn(1),1), 0.01], 1000*i)
ydata[i] = uwreal([model(xdata[i], [1.0 2.0]) + 0.01*getindex(randn(1),1), 0.01], "Point "*string(i))
uwerr(ydata[i]) # We will need the errors for the weights of the fit
end
p0 = [0.5, 0.5];
......@@ -142,9 +141,9 @@ for i in 2:10000
end
# x^2 only measured on odd configurations
x2 = uwreal(x[1:2:9999].^2, 1001, collect(1:2:9999), 10000)
x2 = uwreal(x[1:2:9999].^2, 1001, collect(1:2:9999), "Random walk in [-1,1]")
# x^4 only measured on even configurations
x4 = uwreal(x[2:2:10000].^4, 1001, collect(2:2:10000), 10000)
x4 = uwreal(x[2:2:10000].^4, 1001, collect(2:2:10000), "Random walk in [-1,1]")
```
the variables `x2` and `x4` are normal `uwreal` variables, and one can work with them as with any other variable. Note however that the automatic determination of the summation window can fail in these cases, because the autocorrelation function with missing measurements can be very complicated. For example
```@repl gaps
......@@ -153,9 +152,9 @@ uwerr(rat); # Use automatic window: might fail!
```
In this case `uwerr` complains because with the automatically chosen window the variance for ensemble with ID 1001 is negative. Let's have a look at the normalized autocorrelation function
```@repl gaps
iw = window(rat, 1001)
r = rho(rat, 1001);
dr = drho(rat, 1001);
iw = window(rat, "Random walk in [-1,1]")
r = rho(rat, "Random walk in [-1,1]");
dr = drho(rat, "Random walk in [-1,1]");
plot(collect(1:100),
r[1:100],
yerr = dr[1:100],
......@@ -166,7 +165,7 @@ savefig("rat_cf.png") # hide
The normalized autocorrelation function is oscillating, and the automatically chosen window is 2, producing a negative variance! We better fix the window to 50 for this case
```@repl gaps
wpm = Dict{Int64, Vector{Float64}}()
wpm[1001] = [50.0, -1.0, -1.0, -1.0]
wpm["Random walk in [-1,1]"] = [50.0, -1.0, -1.0, -1.0]
uwerr(rat, wpm) # repeat error analysis with our choice (window=50)
println("Ratio: ", rat)
```
......@@ -175,9 +174,9 @@ Note however that it is very difficult to anticipate which observables will have
```@repl gaps
prod = x2*x4
uwerr(prod)
iw = window(prod, 1001)
r = rho(prod, 1001);
dr = drho(prod, 1001);
iw = window(prod, "Random walk in [-1,1]")
r = rho(prod, "Random walk in [-1,1]");
dr = drho(prod, "Random walk in [-1,1]");
plot(collect(1:2*iw),
r[1:2*iw],
yerr = dr[1:2*iw],
......@@ -197,11 +196,13 @@ All observables are stored in a single `BDIO` record of type `BDIO_BIN_GENERIC`.
- ndata (`Vector{Int32}(neid)`): The length of each ensemble.
- nrep (`Vector{Int32}(neid)`): The number of replica of each enemble.
- vrep (`Vector{Int32}`): The replica vector for each ensemble.
- ids (`Vector{Int32}(neid)`): The ensemble `ID`'s.
- ids (`Vector{Int32}(neid)`): The ensemble numeric `ID`'s.
- nt (`Vector{Int32}(neid)`): Half the largest replica of each ensemble.
- zero (`Vector{Float64}(neid)`): just `neid` zeros.
- four (`Vector{Float64}(neid)`): just `neid` fours.
- delta (`Vector{Float64}`): The fluctuations for each ensemble.
- name (NULL terminated `String`): A description of the observable.
- `ID` tags: A list of `neid` tuples `(Int34, String)` that maps each numeric `ID` to an ensemble tag. All strings are NULL terminated.
!!! alert
Obviously this weird format is what it is for some legacy reasons, but it is strongly encouraged that new implementations respect this standard with all its weirdness.
......
......@@ -19,6 +19,8 @@ const iprm = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
const DEFAULT_STAU = 4.0
const DO_BIN = false
is_int32(str::String) = Base.tryparse(Int32, str) !== nothing
function get_nbin_vec(nd::Array{Int64, 1})::Int64
nbin::Int64 = 1
......@@ -56,25 +58,63 @@ function bin_data(vin::Array{Float64, 1}, nbin::Int64)
return vout
end
function add_DB(delta::Vector{Float64}, id::Int64, iv::Vector{Int64}, ws::wspace)
get_new_id(ws::wspace) = ws.newid = ws.newid - 1
function get_id_from_name(str::String, ws::wspace)
if (haskey(ws.str2id, str))
id = ws.str2id[str]
else
if is_int32(str)
id = Base.tryparse(Int32, str)
else
id = get_new_id(ws)
end
ws.id2str[id] = str
ws.str2id[str] = id
end
return id
end
function get_name_from_id(id::Int64, ws::wspace)
if haskey(ws.id2str, id)
str = ws.id2str[id]
else
str = string(id)
ws.id2str[id] = str
ws.str2id[str] = id
end
return str
end
function add_maps(id::Int64, ws::wspace)
nd = length(delta)
if (nd == 1)
ws.nob += 1
new = fbd(1, 1, delta, [1], Dict{Int64,Vector{Complex{Float64}}}())
push!(ws.fluc, new)
push!(ws.map_nob, id)
if (!haskey(ws.map_ids, id))
ws.map_ids[id] = ws.nob
end
return nothing
end
function add_DB(delta::Vector{Float64}, id::Int64, iv::Vector{Int64}, ws::wspace, do_maps::Bool = true)
nd = length(delta)
if (nd == 1)
new = fbd(1, 1, delta, [1], Dict{Int64,Vector{Complex{Float64}}}())
push!(ws.fluc, new)
else
if (sum(iv) != length(delta))
println(stderr, "ID: ", id)
ArgumentError("Sum of replica length does not match number of measurements")
end
ws.nob += 1
push!(ws.map_nob, id)
if (haskey(ws.map_ids, id))
if (length(delta) != ws.fluc[ws.map_ids[id]].nd)
println(stderr, "ID: ", id)
......@@ -88,8 +128,6 @@ function add_DB(delta::Vector{Float64}, id::Int64, iv::Vector{Int64}, ws::wspace
println(stderr, "obs replica: ", iv)
error("Mistmatch in replica vector for the same ensemble ID")
end
else
ws.map_ids[id] = ws.nob
end
fseries = Dict{Int64,Vector{Complex{Float64}}}()
......@@ -109,9 +147,13 @@ function add_DB(delta::Vector{Float64}, id::Int64, iv::Vector{Int64}, ws::wspace
iv,
fseries)
push!(ws.fluc, new)
end
if do_maps
add_maps(id, ws)
end
return nothing
end
function uwcls(data::Vector{Float64}, id::Int64, ws::wspace, iv::Vector{Int64})
......@@ -634,29 +676,47 @@ end
wsg = ADerrors.wspace(similar(Vector{ADerrors.fbd}, 0),
0,
similar(Vector{Int64}, 0),
Dict{Int64, Int64}())
Dict{Int64, Int64}(),
Dict{Int64, String}(), Dict{String, Int64}(),
-12345)
get_id_from_name(str::String) = get_id_from_name(str, wsg)
taui(a::uwreal, str::String) = taui(a, get_id_from_name(str))
dtaui(a::uwreal, str::String) = dtaui(a, get_id_from_name(str))
window(a::uwreal, str::String) = window(a, get_id_from_name(str))
rho(a::uwreal, str::String) = rho(a, get_id_from_name(str))
drho(a::uwreal, str::String) = drho(a, get_id_from_name(str))
empt = Dict{Int64,Vector{Float64}}()
function dict_name_to_id(wpm::Dict{String, Vector{Float64}})
wp = Dict{Int64, Vector{Float64}}()
for i in keys(wpm)
wp[get_id_from_name(i)] = wpm[i]
end
return wp
end
"""
uwreal(x::Float64)
uwreal([value::Float64, error::Float64], mcid)
uwreal(data::Vector{Float64}, mcid::Int64[, replica::Vector{Int64}])
uwreal(data::Vector{Float64}, mcid::Int64[, replica::Vector{Int64}], idm::Vector{Int64}, nms::Int64)
uwreal(data::Vector{Float64}, mcid[, replica::Vector{Int64}])
uwreal(data::Vector{Float64}, mcid[, replica::Vector{Int64}], idm::Vector{Int64}, nms::Int64)
Returns an `uwreal` data type. Depending on the first argument, the `uwreal` stores the following information:
- Input is a single `Float64`. In this case the variable acts in exactly the same way as a real number. This is understood as a quantity with zero error.
- Input is a 2 element Vector of `Float64` `[value, error]`. In this case the data is understood as `value +/- error`.
- Input is a Vector of `Float64` of length larger than 4. In this case the data is understood as consecutive measurements of an observable in a Monte Carlo (MC) simulation.
In the last two cases, an ensemble `ID` is required as input. Data with the same `ID` are considered as correlated (i.e. fully correlated for the case of a `value +/- error` observables measured on the same sample for the case of data from a MC simulation). For example:
In the last two cases, an ensemble `ID` is required as input. Data with the same `ID` are considered as correlated (i.e. fully correlated for the case of a `value +/- error` observables measured on the same sample for the case of data from a MC simulation). The preferred way to input the ensemble tag is via a `String` that uniquely identifies the ensemble, but an integer is also supported for legacy reasons. For example:
```@example
using ADerrors # hide
a = uwreal([1.2, 0.2], 12) # a = 1.2 +/- 0.2
b = uwreal([1.2, 0.2], 12) # b = 1.2 +/- 0.2
c = uwreal([1.2, 0.2], 2000) # c = 1.2 +/- 0.2
a = uwreal([1.2, 0.2], "Simple var with error") # a = 1.2 +/- 0.2
b = uwreal([1.2, 0.2], "Simple var with error") # b = 1.2 +/- 0.2
c = uwreal([1.2, 0.2], "Another var with error") # c = 1.2 +/- 0.2
d = a-b
uwerr(d)
......@@ -674,7 +734,7 @@ println("e has non zero error because a and c are independent", e)
using ADerrors # hide
# 1000 measurements in three replica of lengths
# 500, 100 and 400
a = uwreal(rand(1000), 12, [500, 100, 400])
a = uwreal(rand(1000), "Ensemble with three replica", [500, 100, 400])
```
### Gaps in the measurements
......@@ -685,11 +745,11 @@ In some situations an observable is not measured in every configuration. In this
using ADerrors # hide
# Observable measured on the odd configurations
# 1, 3, 5, ..., 999 on an emsemble of length 1000
a = uwreal(rand(500), 12, collect(1:2:999), 1000)
a = uwreal(rand(500), "Observable with gaps", collect(1:2:999), 1000)
# Observable measured on the first 900 configurations
# on the same emsemble
b = uwreal(rand(900), 12, collect(1:900), 1000)
b = uwreal(rand(900), "Observable with gaps", collect(1:900), 1000)
```
Note that in this case, if the ensemble has different replica, `sum(replica)` must match `nms`
```@example
......@@ -697,33 +757,78 @@ using ADerrors # hide
# Observable measured on the even configurations
# 2, 4, 6, ..., 200 on an emsemble of length 200
# with two replica of lengths 75, 125
a = uwreal(data_a[1:500], 123, [75, 125], collect(2:2:200), 200)
a = uwreal(data_a[1:500], "Observable with gaps in an ensemble with replica", [75, 125], collect(2:2:200), 200)
```
"""
uwreal(x::Float64) = ADerrors.uwreal(x, 0.0, 0.0,
Vector{Bool}(), Vector{Float64}(),
Vector{Int64}(), Vector{cfdata}())
uwreal(data::Vector{Float64}, id::Int64) = ADerrors.uwcls(data::Vector{Float64}, id::Int64, wsg, [length(data)])
uwreal(data::Vector{Float64}, id::Int64, iv::Vector{Int64}) = ADerrors.uwcls(data::Vector{Float64}, id::Int64, wsg, iv)
uwreal(data::Vector{Float64}, id::Int64, idm::Vector{Int64}, nms::Int64) = ADerrors.uwcls_gaps(data::Vector{Float64},
id::Int64, wsg,
uwreal(data::Vector{Float64},
id::Int64) = ADerrors.uwcls(data,
id,
wsg,
[length(data)])
uwreal(data::Vector{Float64},
id::Int64,
iv::Vector{Int64}) = ADerrors.uwcls(data,
id,
wsg,
iv)
uwreal(data::Vector{Float64},
id::Int64,
idm::Vector{Int64},
nms::Int64) = ADerrors.uwcls_gaps(data,
id,
wsg,
[nms],
idm,
nms)
uwreal(data::Vector{Float64},
id::Int64,
iv::Vector{Int64},
idm::Vector{Int64},
nms::Int64)
uwreal(data::Vector{Float64}, id::Int64, iv::Vector{Int64}, idm::Vector{Int64}, nms::Int64) = ADerrors.uwcls_gaps(data::Vector{Float64},
id::Int64, wsg,
nms::Int64) = ADerrors.uwcls_gaps(data,
id,
wsg,
iv,
idm,
nms)
uwreal(data::Vector{Float64}, str::String) = ADerrors.uwcls(data,
get_id_from_name(str, wsg),
wsg,
[length(data)])
uwreal(data::Vector{Float64},
str::String,
iv::Vector{Int64}) = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv)
uwreal(data::Vector{Float64},
str::String,
idm::Vector{Int64},
nms::Int64) = ADerrors.uwcls_gaps(data,
get_id_from_name(str, wsg), wsg,
[nms],
idm,
nms)
uwreal(data::Vector{Float64},
str::String,
iv::Vector{Int64},
idm::Vector{Int64},
nms::Int64)
nms::Int64) = ADerrors.uwcls_gaps(data,
get_id_from_name(str, wsg),
iv,
idm,
nms)
@doc raw"""
uwerr(a::uwreal[, wpm::Dict{Int64,Vector{Float64}}])
uwerr(a::uwreal[, wpm::Dict{String,Vector{Float64}}])
Performs error analysis on the observable `a`.
```@example
using ADerrors # hide
a = uwreal([1.3, 0.01], 1) # 1.3 +/- 0.01
a = uwreal([1.3, 0.01], "Var with error") # 1.3 +/- 0.01
b = sin(2.0*a)
uwerr(b)
println("Look how I propagate errors: ", b)
......@@ -762,58 +867,58 @@ for i in 2:1000
end
# Load the data in a uwreal
a = uwreal(x.^2, 1233)
wpm = Dict{Int64,Vector{Float64}}()
a = uwreal(x.^2, "Random walk in [-1,1]")
wpm = Dict{String,Vector{Float64}}()
# Use default analysis (stau = 4.0)
uwerr(a)
println("default: ", a, " (tauint = ", taui(a, 1233), ")")
println("default: ", a, " (tauint = ", taui(a, "Random walk in [-1,1]"), ")")
# This will still do default analysis because
# a does not depend on emsemble 300
wpm[300] = [-1.0, 8.0, -1.0, 145.0]
# a does not depend on emsemble foo
wpm["Ensemble foo"] = [-1.0, 8.0, -1.0, 145.0]
uwerr(a, wpm)
println("default: ", a, " (tauint = ", taui(a, 1233), ")")
println("default: ", a, " (tauint = ", taui(a, "Random walk in [-1,1]"), ")")
# Fix the summation window to 1 (i.e. uncorrelated data)
wpm[1233] = [1.0, -1.0, -1.0, -1.0]
wpm["Random walk in [-1,1]"] = [1.0, -1.0, -1.0, -1.0]
uwerr(a, wpm)
println("uncorrelated: ", a, " (tauint = ", taui(a, 1233), ")")
println("uncorrelated: ", a, " (tauint = ", taui(a, "Random walk in [-1,1]"), ")")
# Use stau = 1.5
wpm[1233] = [-1.0, 1.5, -1.0, -1.0]
wpm["Random walk in [-1,1]"] = [-1.0, 1.5, -1.0, -1.0]
uwerr(a, wpm)
println("stau = 1.5: ", a, " (tauint = ", taui(a, 1233), ")")
println("stau = 1.5: ", a, " (tauint = ", taui(a, "Random walk in [-1,1]"), ")")
# Use fixed window 15 and add tail with texp = 100.0
wpm[1233] = [15.0, -1.0, -1.0, 100.0]
wpm["Random walk in [-1,1]"] = [15.0, -1.0, -1.0, 100.0]
uwerr(a, wpm)
println("Fixed window 15, texp=100: ", a, " (tauint = ", taui(a, 1233), ")")
println("Fixed window 15, texp=100: ", a, " (tauint = ", taui(a, "Random walk in [-1,1]"), ")")
# Sum up to the point that the signal in Gamma is
# 1.5 times the error and add a tail with texp = 30.0
wpm[1233] = [-1.0, -1.0, 1.5, 30.0]
# 1.5 times the error and add a tail with texp = 10.0
wpm["Random walk in [-1,1]"] = [-1.0, -1.0, 1.5, 30.0]
uwerr(a, wpm)
println("signal/noise=1.5, texp=30: ", a, " (tauint = ", taui(a, 1233), ")")
println("signal/noise=1.5, texp=10: ", a, " (tauint = ", taui(a, "Random walk in [-1,1]"), ")")
```
"""
uwerr(a::uwreal, wpm::Dict{Int64,Vector{Float64}}) = ADerrors.uwerror(a::uwreal, wsg, wpm)
uwerr(a::uwreal, wpm::Dict{Int64,Vector{Float64}}) = ADerrors.uwerror(a, wsg, wpm)
uwerr(a::uwreal) = ADerrors.uwerror(a::uwreal, wsg, empt)
uwerr(a::uwreal, wpm::Dict{String,Vector{Float64}}) = uwerr(a, dict_name_to_id(wpm))
"""
cov(a::Vector{uwreal}[, wpm::Dict{Int64,Vector{Float64}}])
cov(a::Vector{uwreal}[, wpm])
Determine the covariance matrix between the vector of observables `a[:]`.
```@example
using ADerrors, LinearAlgebra # hide
a = uwreal([1.3, 0.01], 1) # 1.3 +/- 0.01
b = uwreal([5.3, 0.23], 2) # 5.3 +/- 0.23
a = uwreal([1.3, 0.01], "Var 1") # 1.3 +/- 0.01
b = uwreal([5.3, 0.23], "Var 2") # 5.3 +/- 0.23
uwerr(a)
uwerr(b)
x = [a+b, a-b]
mat = cov(x)
mat = ADerrors.cov(x)
println("Covariance: ", mat[1,1], " ", mat[1,2])
println(" ", mat[2,1], " ", mat[2,2])
println("Check (should be zero): ", mat[1,1] - mat[2,2])
......@@ -825,17 +930,19 @@ println("Check (should be zero): ", mat[1,2] - (err(a)^2-err(b)^2))
An optional parameter `wpm` can be used to choose the summation window for the relevant autocorrelation functions. The situation is completely analogous to the case of error analysis of single variables.
"""
cov(a::Vector{uwreal}) = cov(a::Vector{uwreal}, wsg, empt)
cov(a::Vector{uwreal}, wpm::Dict{Int64,Vector{Float64}}) = cov(a::Vector{uwreal}, wsg, wpm::Dict{Int64,Vector{Float64}})
cov(a::Vector{uwreal}, wpm::Dict{Int64,Vector{Float64}}) = cov(a, wsg, wpm)
cov(a::Vector{uwreal}, wpm::Dict{String,Vector{Float64}}) = cov(a, wsg, dict_name_to_id(wpm))
@doc raw"""
trcov(M::Array{Float64, 2}, a::Vector{uwreal})
trcov(M::Array{Float64, 2}, a::Vector{uwreal}[, wmp])
Given a vector of `uwreal`, `a[:]` and a two dimensional array `M`, this routine computes ``{\rm tr}(MC)``, where ``C_{ij} = {\rm cov}(a[i], a[j])``.
Given a vector of `uwreal`, `a[:]` and a two dimensional symmtric positive definite array `M`, this routine computes ``{\rm tr}(MC)``, where ``C_{ij} = {\rm cov}(a[i], a[j])``.
```@example
using ADerrors, LinearAlgebra # hide
a = uwreal([1.3, 0.01], 1) # 1.3 +/- 0.01
b = uwreal([5.3, 0.23], 2) # 5.3 +/- 0.23
c = uwreal(rand(2000), 3)
a = uwreal([1.3, 0.01], "Var with error 1") # 1.3 +/- 0.01
b = uwreal([5.3, 0.23], "Var with error 2") # 5.3 +/- 0.23
c = uwreal(rand(2000), "White noise ensemble")
x = [a+b+sin(c), a-b+cos(c), c-b/a]
M = [1.0 0.2 0.1
......@@ -845,17 +952,27 @@ M = [1.0 0.2 0.1
mcov = cov(x)
d = tr(mcov * M)
println("Better be zero: ", d -trcov(M, x))
# Case of Monte Carlo data
An optional parameter `wpm` can be used to choose the summation window for the relevant autocorrelation functions. The situation is completely analogous to the case of error analysis of single variables.
```
"""
trcov(M, a::Vector{uwreal}) = trcov(M, a::Vector{uwreal}, wsg, empt)
trcov(M, a::Vector{uwreal}, wpm::Dict{Int64,Vector{Float64}}) = trcov(M, a::Vector{uwreal}, wsg, wpm::Dict{Int64,Vector{Float64}})
trcov(M, a::Vector{uwreal}) = trcov(M, a, wsg, empt)
trcov(M, a::Vector{uwreal}, wpm::Dict{Int64,Vector{Float64}}) = trcov(M, a, wsg, wpm)
trcov(M, a::Vector{uwreal}, wpm::Dict{String,Vector{Float64}}) =
trcov(M, a, wsg, dict_name_to_id(wpm))
trcorr(M, a::Vector{uwreal},
W::Vector{Float64}=Vector{Float64}()) = trcorr(M, a::Vector{uwreal}, wsg, empt, W)
W::Vector{Float64}=Vector{Float64}()) = trcorr(M, a, wsg, empt, W)
trcorr(M, a::Vector{uwreal}, W::Vector{Float64},
wpm::Dict{Int64,Vector{Float64}}) = trcorr(M, a, wsg, wpm, W)
trcorr(M, a::Vector{uwreal}, W::Vector{Float64},
wpm::Dict{String,Vector{Float64}}) = trcorr(M, a, wsg, dict_name_to_id(wpm), W)
trcorr(M, a::Vector{uwreal},
W::Vector{Float64}, wpm::Dict{Int64,Vector{Float64}}) = trcorr(M, a::Vector{uwreal}, wsg, wpm::Dict{Int64,Vector{Float64}}, W)
wpm::Dict{Int64,Vector{Float64}}) = trcorr(M, a, wsg, wpm, Vector{Float64}())
trcorr(M, a::Vector{uwreal},
wpm::Dict{Int64,Vector{Float64}}) = trcorr(M, a::Vector{uwreal}, wsg, wpm::Dict{Int64,Vector{Float64}}, Vector{Float64}())
wpm::Dict{String,Vector{Float64}}) = trcorr(M, a, wsg, dict_name_to_id(wpm), Vector{Float64}())
"""
......
......@@ -74,9 +74,9 @@ function derror(a::uwreal)
end
"""
taui(a::uwreal, id::Int64)
taui(a::uwreal, mcid)
Returns the value of tauint for the ensemble `id`. It is assumed that `uwerr` has been run on the variable and that `id` contributes to the observable `a`. Otherwise an error message is printed.
Returns the value of tauint for the ensemble `mcid`. It is assumed that `uwerr` has been run on the variable and that `mcid` contributes to the observable `a`. Otherwise an error message is printed. `mcid` can be either an `Int64` (the proper ensemble ID), or a `String` (the ensemble tag).
```@example
using ADerrors # hide
# Generate some correlated data
......@@ -90,9 +90,9 @@ for i in 2:1000
end
end
a = uwreal(x.^2, 666)
a = uwreal(x.^2, "Some simple ensemble")
uwerr(a)
println("Error analysis result: ", a, " (tauint = ", taui(a, 666), ")")
println("Error analysis result: ", a, " (tauint = ", taui(a, "Some simple ensemble"), ")")
```
"""
function taui(a::uwreal, mcid::Int64)
......@@ -105,9 +105,9 @@ function taui(a::uwreal, mcid::Int64)
end
"""
dtaui(a::uwreal, id::Int64)
dtaui(a::uwreal, mcid)
Returns an estimate on the error of tauint for the ensemble `id`. It is assumed that `uwerr` has been run on the variable and that `id` contributes to the observable `a`. Otherwise an error message is printed.
Returns an estimate on the error of tauint for the ensemble `mcid`. It is assumed that `uwerr` has been run on the variable and that `mcid` contributes to the observable `a`. Otherwise an error message is printed.
```@example
using ADerrors # hide
# Generate some correlated data
......@@ -121,10 +121,10 @@ for i in 2:1000
end
end
a = uwreal(x.^2, 666)
a = uwreal(x.^2, "Some simple ensemble")
uwerr(a)
println("Error analysis result: ", a,
" (tauint = ", taui(a, 666), " +/- ", dtaui(a, 666), ")")
" (tauint = ", taui(a, "Some simple ensemble"), " +/- ", dtaui(a, "Some simple ensemble"), ")")
```
"""
function dtaui(a::uwreal, mcid::Int64)
......@@ -137,9 +137,9 @@ function dtaui(a::uwreal, mcid::Int64)
end
"""
window(a::uwreal, id::Int64)
window(a::uwreal, mcid)
Returns the summation window for the ensemble `id`. It is assumed that `uwerr` has been run on the variable and that `id` contributes to the observable `a`. Otherwise an error message is printed.
Returns the summation window for the ensemble `mcid`. It is assumed that `uwerr` has been run on the variable and that `mcid` contributes to the observable `a`. Otherwise an error message is printed.
```@example
using ADerrors # hide
# Generate some correlated data
......@@ -153,10 +153,10 @@ for i in 2:1000
end
end
a = uwreal(x.^2, 666)
a = uwreal(x.^2, "Some simple ensemble")
uwerr(a)
println("Error analysis result: ", a,
" (window = ", window(a, 666), ")")
" (window = ", window(a, "Some simple ensemble"), ")")
```
"""
function window(a::uwreal, mcid::Int64)
......@@ -169,9 +169,9 @@ function window(a::uwreal, mcid::Int64)
end
"""
rho(a::uwreal, id::Int64)
rho(a::uwreal, mcid)
Returns the normalized autocorrelation function of `a` for the ensemble `id`. It is assumed that `uwerr` has been run on the variable and that `id` contributes to the observable `a`. Otherwise an error message is printed.
Returns the normalized autocorrelation function of `a` for the ensemble `mcid`. It is assumed that `uwerr` has been run on the variable and that `mcid` contributes to the observable `a`. Otherwise an error message is printed.
```@example
using ADerrors # hide
# Generate some correlated data
......@@ -185,9 +185,9 @@ for i in 2:1000
end
end
a = uwreal(x.^2, 666)
a = uwreal(x.^2, "Some simple ensemble")
uwerr(a)
v = rho(a, 666)
v = rho(a, "Some simple ensemble")
for i in 1:length(v)
println(i, " ", v[i])
end
......@@ -203,9 +203,9 @@ function rho(a::uwreal, mcid::Int64)
end
"""
rho(a::uwreal, id::Int64)
drho(a::uwreal, mcid)
Returns an estimate of the error on the normalized autocorrelation function of `a` for the ensemble `id`. It is assumed that `uwerr` has been run on the variable and that `id` contributes to the observable `a`. Otherwise an error message is printed.
Returns an estimate of the error on the normalized autocorrelation function of `a` for the ensemble `mcid`. It is assumed that `uwerr` has been run on the variable and that `mcid` contributes to the observable `a`. Otherwise an error message is printed.
```@example
using ADerrors # hide
# Generate some correlated data
......@@ -219,10 +219,10 @@ for i in 2:1000
end
end
a = uwreal(x.^2, 666)
a = uwreal(x.^2, "Some simple ensemble")
uwerr(a)
v = rho(a, 666)
dv = drho(a, 666)
v = rho(a, "Some simple ensemble")
dv = drho(a, "Some simple ensemble")
for i in 1:length(v)
println(i, " ", v[i], " +/- ", dv[i])
end
......@@ -278,15 +278,33 @@ function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64})
dfl = zeros(Float64, nds[i])
BDIO.BDIO_read(fb, dfl)
id = convert(Int64, ids[i])
add_DB(dfl, get(mapids, id, id), convert(Vector{Int64}, ivrep[is:ie]), ws)
add_DB(dfl, get(mapids, id, id), convert(Vector{Int64}, ivrep[is:ie]), ws, false)
is = ie + 1
end
if BDIO.BDIO_eor(fb)
for i in 1:nid
id = convert(Int64, ids[i])
add_maps(id, ws)
get_name_from_id(id, ws)
end
else
name = BDIO.BDIO_read_str(fb)
for i in 1:nid
BDIO.BDIO_read(fb, ifoo)
str = BDIO.BDIO_read_str(fb)
id = get_id_from_name(str, ws)
add_maps(id, ws)
end
end
return uwreal(dfoo[1], p, d)
end
function write_bdio(p::uwreal, fb, iu::Int, ws::wspace)
function write_bdio(p::uwreal, fb, iu::Int, ws::wspace; name="NO NAME")
BDIO.BDIO_start_record!(fb, BDIO.BDIO_BIN_GENERIC, convert(Int32, iu), true)
nid = convert(Int32, unique_ids!(p, ws))
......@@ -329,6 +347,12 @@ function write_bdio(p::uwreal, fb, iu::Int, ws::wspace)
BDIO.BDIO_write!(fb, dt, true)
end
BDIO.BDIO_write!(fb, name*"\0")
for i in 1:nid
BDIO.BDIO_write!(fb, [convert(Int32, p.ids[i])])
BDIO.BDIO_write!(fb, get_name_from_id(p.ids[i], ws)*"\0")
end
BDIO.BDIO_write_hash!(fb)
return true
......@@ -341,24 +365,21 @@ Write out a detailed information on the error of `a`.
## Arguments
Optionally one can pass as a keyword argument (`io`) the `IO` stream to write to and a dictionary (`names`) that translates ensemble `ID`s into more human friendly `Strings`
Optionally one can pass as a keyword argument (`io`) the `IO` stream to write to.
## Example
```@example
using ADerrors # hide
a = uwreal(rand(2000), 120)
b = uwreal([1.2, 0.023], 121)
c = uwreal([5.2, 0.03], 122)
a = uwreal(rand(2000), "Ensemble A12")
b = uwreal([1.2, 0.023], "Ensemble XYZ")
c = uwreal([5.2, 0.03], "Ensemble RRR")
d = a + b - c
uwerr(d)
bnm = Dict{Int64, String}()
bnm[120] = "Very important ensemble"
bnm[122] = "H12B K87"
details(d, bnm)
details(d)
```
"""
function details(a::uwreal, ws::wspace, io::IO=stdout, names::Dict{Int64, String} = Dict{Int64, String}())
function details(a::uwreal, ws::wspace, io::IO=stdout)
if (length(a.prop) == 0)
print(a.mean)
......@@ -390,7 +411,7 @@ function details(a::uwreal, ws::wspace, io::IO=stdout, names::Dict{Int64, String
for i in 1:length(a.cfd)
idx = ws.map_ids[a.ids[ip[i]]]
sndt = join(ws.fluc[idx].ivrep, ",")
sid = truncate_ascii(get(names, a.ids[ip[i]], string(a.ids[ip[i]])), ntrunc)
sid = truncate_ascii(get_name_from_id(a.ids[ip[i]], ws), ntrunc)
if (ws.fluc[idx].nd > 1)
Printf.@printf(io, " # %45s %6.2f %s\n",
sid, 100.0 .* a.cfd[ip[i]].var ./ a.err^2, sndt)
......@@ -404,7 +425,7 @@ function details(a::uwreal, ws::wspace, io::IO=stdout, names::Dict{Int64, String
end
end
details(a::uwreal; io::IO=stdout, names::Dict{Int64, String} = Dict{Int64, String}()) = details(a, wsg, io, names)
details(a::uwreal; io::IO=stdout) = details(a, wsg, io)
"""
read_uwreal(fb[, map_ids::Dict{Int64, Int64}])
......
......@@ -10,9 +10,10 @@
###
"""
cobs(avgs::Vector{Float64}, Mcov::Array{Float64, 2}, str::String)
cobs(avgs::Vector{Float64}, Mcov::Array{Float64, 2}, ids::Vector{Int64})
Returns a vector of `uwreal` such that their mean values are `avgs[:]` and their covariance is `Mcov[:,:]`. In order to construct these observables `n=length(avgs)` ensemble ID are used. These have to be specified in the vector `ids[:]`.
Returns a vector of `uwreal` such that their mean values are `avgs[:]` and their covariance is `Mcov[:,:]`. In order to construct these observables `n=length(avgs)` ensemble ID are used. These are generated either from the string `str` or have to be specified in the vector `ids[:]`.
```@example
using ADerrors # hide
# Put some average values and covariance
......@@ -23,7 +24,7 @@ Mcov = [0.478071 -0.176116 0.0135305
# Produce observables with ensemble ID
# [1, 2001, 32]. Do error analysis
p = cobs(avg, Mcov, [1, 2001, 32])
p = cobs(avg, Mcov, "GF beta function parameters")
uwerr.(p)
# Check central values are ok
......@@ -50,6 +51,19 @@ function cobs(avgs::Vector{Float64}, cov::Array{Float64, 2}, ids::Vector{Int64})
return p
end
function cobs(avgs::Vector{Float64}, cov::Array{Float64, 2}, str::String)
n = length(avgs)
ids = Vector{Int64}(undef, n)
for i in 1:n
tstr = Printf.@sprintf "%s %8.8d" str i
ids[i] = get_id_from_name(tstr)
end
return cobs(avgs, cov, ids)
end
function addobs(a::Vector{uwreal}, der::Vector{Float64}, mvl::Float64)
n = 0
......
......@@ -73,6 +73,11 @@ mutable struct wspace
map_nob::Array{Int64, 1} # The id that corresponds to each ob
map_ids::Dict{Int64, Int64} # For each id, a fluc index
id2str::Dict{Int64, String} # Ensemble id for each String
str2id::Dict{String, Int64} # Ensemble String for each id
newid::Int64
end
......
......@@ -17,9 +17,9 @@ Returns `x` such that `fnew(x, data) = 0` (i.e. a root of the function). The err
using ADerrors # hide
# First define some arbitrary data
data = Vector{uwreal}(undef, 3)
data[1] = uwreal([1.0, 0.2], 120)
data[2] = uwreal([1.2, 0.023], 121)
data[3] = uwreal(rand(1000), 122)
data[1] = uwreal([1.0, 0.2], "Var A")
data[2] = uwreal([1.2, 0.023], "Var B")
data[3] = uwreal(rand(1000), "White noise ensemble")
# Now define a function
f(x, p) = x + p[1]*x + cos(p[2]*x+p[3])
......@@ -33,7 +33,8 @@ println("Root: ", x)
# Check
z = f(x, data)
uwerr(z)
println("Better be zero (with zero error): ", z)
print("Better be zero (with zero error): ")
details(z)
```
"""
function root_error(fnew::Function, x::Float64,
......@@ -59,7 +60,7 @@ function root_error(fnew::Function, x::Float64,
return addobs(data, -gw ./ grad[1], xv[1])
end
function chiexp(hess::Array{Float64, 2}, data::Vector{uwreal}, W::Vector{Float64})
function chiexp(hess::Array{Float64, 2}, data::Vector{uwreal}, W::Vector{Float64}, wpm::Dict{Int64,Vector{Float64}})
m = length(data)
n = size(hess, 1) - m
......@@ -77,10 +78,10 @@ function chiexp(hess::Array{Float64, 2}, data::Vector{uwreal}, W::Vector{Float64
Px[i,i] = W[i] + Px[i,i]
end
return trcov(Px, data)
return trcov(Px, data, wpm)
end
function chiexp(hess::Array{Float64, 2}, data::Vector{uwreal}, W::Array{Float64, 2})
function chiexp(hess::Array{Float64, 2}, data::Vector{uwreal}, W::Array{Float64, 2}, wpm::Dict{Int64,Vector{Float64}})
m = length(data)
n = size(hess, 1) - m
......@@ -95,7 +96,7 @@ function chiexp(hess::Array{Float64, 2}, data::Vector{uwreal}, W::Array{Float64,
hi = LinearAlgebra.pinv(maux)
Px = W - hm' * hi * hm
return trcov(Px, data)
return trcov(Px, data, wpm)
end
@doc raw"""
......@@ -153,8 +154,9 @@ println("chi^2 / chi_exp^2: ", chisq(xp, value.(dt)), " / ", chiexp(chisq, xp, d
"""
function chiexp(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal};
W = Vector{Float64}())
data::Vector{uwreal},
wpm::Dict{Int64,Vector{Float64}};
W::Vector{Float64} = Vector{Float64}())
n = length(xp) # Number of fit parameters
m = length(data) # Number of data
......@@ -182,7 +184,7 @@ function chiexp(chisq::Function,
Ww = zeros(Float64, m)
for i in 1:m
if (data[i].err == 0.0)
uwerr(data[i])
uwerr(data[i], wpm)
if (data[i].err == 0.0)
error("Zero error in fit data")
end
......@@ -193,15 +195,28 @@ function chiexp(chisq::Function,
Ww = W
end
cse = chiexp(hess, data, Ww)
cse = chiexp(hess, data, Ww, wpm)
end
return cse
end
chiexp(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal};
W::Vector{Float64} = Vector{Float64}()) =
chiexp(chisq, xp, data, Dict{Int64,Vector{Float64}}(), W)
chiexp(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal},
wpm::Dict{String,Vector{Float64}};
W::Vector{Float64} = Vector{Float64}()) =
chiexp(chisq, xp, data, dict_names_to_id(wpm), W)
@doc raw"""
fit_error(chisq::Function, xp::Vector{Float64}, data::Vector{uwreal};
fit_error(chisq::Function, xp::Vector{Float64}, data::Vector{uwreal}[, wpm];
W = Vector{Float64}(), chi_exp = true)
Given a ``\chi^2(p, d)``, function of the fit parameters `p[:]` and the data `d[:]`, this routine return the fit parameters as `uwreal` type and optionally, the expected value of ``\chi^2(p, d)``.
......@@ -215,6 +230,7 @@ Given a ``\chi^2(p, d)``, function of the fit parameters `p[:]` and the data `d[
where the function ``f_i(p)`` is an arbitrary function of the fit parameters. In simple words, the expected ``\chi^2(p, d)`` is determined assuming that the function ``\chi^2(p, d)`` is quadratic in the data.
- `xp`: A vector of `Float64`. The value of the fit parameters at the minima.
- `data`: A vector of `uwreal`. The data whose fluctuations enter in the evaluation of the `chisq`.
- `wpm`: `Dict{Int64,Vector{Float64}}` or `Dict{String,Vector{Float64}}`. The criteria to determine the summation window. See the documentation on `uwerr` function for more details.
- `W`: A matrix. The weights that enter in the evaluation of the `chisq` function. If a vector is passed, the matrix is assumed to be diagonal (i.e. **uncorrelated** fit). If no weights are passed, the routines assumes that `W` is diagonal with entries given by the inverse errors squared of the data (i.e. the `chisq` is weighted with the errors of the data).
- `chi_exp`: Bool type. If false, do not compute the expected ``\chi^2(p, d)``.
......@@ -239,7 +255,7 @@ vs = rand(dmv, 1)
# Create the uwreal data that we want to
# fit to a constant
dt = cobs(vs[:,1], sig, [100+n for n in 1:npt])
dt = cobs(vs[:,1], sig, "Data points")
# Define the chi^2
chisq(p, d) = sum( (d .- p[1]) .^ 2 ./ dx .^2 )
......@@ -254,14 +270,18 @@ xp = [sum(value.(dt) ./ dx)/sum(1.0 ./ dx)]
(fitp, csqexp) = fit_error(chisq, xp, dt)
uwerr.(fitp)
println("Fit parameter: ", fitp[1])
println("chi^2 / chi_exp^2: ", chisq(xp, value.(dt)), " / ", csqexp)
println(" *** FIT RESULTS ***")
print("Fit parameter: ")
details.(fitp)
println("chi^2 / chi_exp^2: ", chisq(xp, value.(dt)), " / ", csqexp, " (dof: ", npt-1, ")")
```
"""
function fit_error(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal};
W = Vector{Float64}(), chi_exp = true)
data::Vector{uwreal},
wpm::Dict{Int64,Vector{Float64}};
W::Vector{Float64} = Vector{Float64}(),
chi_exp::Bool = true)
n = length(xp) # Number of fit parameters
m = length(data) # Number of data
......@@ -301,7 +321,7 @@ function fit_error(chisq::Function,
Ww = zeros(Float64, m)
for i in 1:m
if (data[i].err == 0.0)
uwerr(data[i])
uwerr(data[i], wpm)
if (data[i].err == 0.0)
error("Zero error in fit data")
end
......@@ -312,12 +332,87 @@ function fit_error(chisq::Function,
Ww = W
end
cse = chiexp(hess, data, Ww)
cse = chiexp(hess, data, Ww, wpm)
end
return param, cse
end
function fit_error(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal},
wpm::Dict{Int64,Vector{Float64}},
W::Array{Float64, 2};
chi_exp::Bool = true)
n = length(xp) # Number of fit parameters
m = length(data) # Number of data
xav = Vector{Float64}(undef, n+m)
for i in 1:n
xav[i] = xp[i]
end
for i in n+1:n+m
xav[i] = data[i-n].mean
end
ccsq(x::Vector) = chisq(x[1:n], x[n+1:n+m])
if (n+m < 4)
cfg = ForwardDiff.HessianConfig(ccsq, xav, Chunk{1}());
else
cfg = ForwardDiff.HessianConfig(ccsq, xav, Chunk{4}());
end
hess = Array{Float64}(undef, n+m, n+m)
ForwardDiff.hessian!(hess, ccsq, xav, cfg)
hm = view(hess, 1:n, 1:n)
sm = view(hess, 1:n, n+1:n+m)
hinv = LinearAlgebra.pinv(hm)
grad = - hinv * sm
param = addobs(data, grad, xp)
if (!chi_exp)
return param
end
cse = 0.0
if (m-n > 0)
cse = chiexp(hess, data, W, wpm)
end
return param, cse
end
fit_error(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal};
W::Vector{Float64} = Vector{Float64}(),
chi_exp::Bool = true) =
fit_error(chisq, xp, data, Dict{Int64,Vector{Float64}}(), W=W, chi_exp=chi_exp)
fit_error(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal},
W::Array{Float64,2};
chi_exp::Bool = true) =
fit_error(chisq, xp, data, Dict{Int64,Vector{Float64}}(), W=W, chi_exp=chi_exp)
fit_error(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal},
wpm::Dict{String,Vector{Float64}};
W::Vector{Float64} = Vector{Float64}(),
chi_exp::Bool = true) =
fit_error(chisq, xp, data, dict_names_to_id(wpm), W=W, chi_exp=chi_exp)
fit_error(chisq::Function,
xp::Vector{Float64},
data::Vector{uwreal},
wpm::Dict{String,Vector{Float64}},
W::Array{Float64,2};
chi_exp::Bool = true) =
fit_error(chisq, xp, data, dict_names_to_id(wpm), W=W, chi_exp=chi_exp)
@doc raw"""
int_error(fint::Function, a, b, p::Vector{uwreal})
......@@ -334,11 +429,11 @@ using ADerrors
# here we try to reproduce the result
# Scale ratio = 21.86(42) Eq.5.6
avg = [16.26, 0.12, -0.0038]
Mcov = [0.478071 -0.176116 0.0135305
Mcov = [ 0.478071 -0.176116 0.0135305
-0.176116 0.0696489 -0.00554431
0.0135305 -0.00554431 0.000454180]
p = cobs(avg, Mcov, [1, 2001, 32])
p = cobs(avg, Mcov, "Beta function fit parameters")
g1s = uwreal([2.6723, 0.0064], 4)
g2s = 11.31
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment