diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..53f572a --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,16 @@ +name: TagBot +on: + issue_comment: # THIS BIT IS NEW + types: + - created + workflow_dispatch: +jobs: + TagBot: + # THIS 'if' LINE IS NEW + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + # NOTHING BELOW HAS CHANGED + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bcee700 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +Manifest.toml \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..24358b3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018-2021: Raphael Saavedra, Guilherme Bodin, Mario Souto + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/Project.toml b/Project.toml index 05353b9..2d85fbb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NonParametricNORTA" uuid = "e97a57fc-2266-4ea9-80d8-a1f12fb1471b" authors = ["andreramosfc "] -version = "0.1.1" +version = "0.2.0" [deps] Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" @@ -10,3 +10,9 @@ KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +julia = "1" +Distributions = "0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25" +Interpolations = "0.14, 0.15" +KernelDensity = "0.5, 0.6" \ No newline at end of file diff --git a/README.md b/README.md index 7c45e89..365d6f1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ using Plots using Distributions y = rand(1000, 3)*rand(3).*15 #generate y as a regression -y_norta, non_parametric_distribution = NonParametricNORTA.convertData(y) +y_norta, non_parametric_distribution = NonParametricNORTA.convert_data(y) ``` ### Transformation visualization @@ -26,7 +26,7 @@ This transformation involves obtaining the non-parametric distribution's cumulat ## Data reverse transformation ```julia -sc = NonParametricNORTA.reverseData(rand(Normal(0, 1), 100), non_parametric_distribution) +sc = NonParametricNORTA.reverse_data(rand(Normal(0, 1), 100), non_parametric_distribution) ``` ### Reverse transformation visualization @@ -36,54 +36,55 @@ Similar to the initial transformation but in reverse, this process involves reve In time series simulation processes within stationary contexts, maintaining scenarios that respect historical value bounds becomes crucial. Ensuring scenarios do not violate the maximum and minimum values can be achieved by modeling the transformed NORTA series and then performing the reverse transformation process. -### Regression + residual bootstraping example +### Simulation of Water Inflows -```julia -T = 1000 -train_idx = 1:900 -test_idx = 901:1000 -N_scenarios = 100 - -X = rand(T, 10) -X_train = X[train_idx, :] -X_test = X[test_idx, :] - -y = X*(rand(10).*10) + rand(T) -y_train = y[train_idx] -y_test = y[test_idx] +In this example we want to generate scenario paths for a water inflow time series. We will make two simulations using an Auto ARIMA (estimated vi StateSpaceModels.jl package). The first one will be the simple output of the model and the second one will be utilizing the NORTA transformation. -y_train_norta, np = NonParametricNORTA.convertData(y_train) +```julia +using StateSpaceModels, CSV, DataFrames, Plots +df = CSV.read("datasets/inflows.csv") -β = X_train\y_train_norta #Model the NORTA transformed data -residuals = y_train_norta - X_train*β +y = df[!, 2] +dates = df[!, 1] +forecast_dates = collect(Date(2015, 1, 1): Month(1): Date(2016, 12, 1)) +steps_ahead = 24 -NORTA_scenarios = zeros(length(y_test), N_scenarios) -for i in 1:N_scenarios - NORTA_scenarios[:, i] = X[T_train+1:T, :]*β + rand(residuals, length(y_test)) -end ``` -#### Transformed data results +#### Simulating Original Time Series ```julia -plot(y_train_norta, w=2, color = "black", lab = "NORTA transformed historic", legend=:outerbottom) -for i in 1:N_scenarios - plot!(vcat(ones(T_train).*NaN, NORTA_scenarios[:, i]), color = "red", alpha = 0.2, lab = "") -end -plot!([], color="red", lab = "NORTA transformed scenarios") +model = auto_arima(y; seasonal = 12) +fit!(model) +scenarios = simulate_scenarios(model, 24, 100)[:, 1, :] +expected_value = [i[1] for i in forecast(model, 24).expected_value] + +plt = plot(dates, y, label = "Historical Values", color = :black, w=2, legend=:outertop) +plot!(plt, forecast_dates, scenarios, label = "", color = "grey", width = 0.2) +plot!(forecast_dates, expected_value.*NaN, color = "grey", label="Scenarios") +plot!(forecast_dates, expected_value, lab = "Expected Value", color = :red) + ``` -![norta_simulation](./docs/figures/norta_sim.PNG) +![simulation](./docs/figures/inflow_simulation.PNG) -The modeled simulation, when visualized in the transformed scale, does not adhere to historical bounds. This is evident as the maximum and minimum of the simulation exceed historical boundaries. +The modeled simulation does not adhere to historical bounds. This is evident as, in this case, the minimum of the simulation is below historical boundaries. -#### Original scale data results +#### Simulating utilizing NORTA ```julia -scenarios = NonParametricNORTA.reverseData(NORTA_scenarios, np) +transformed_y, non_parametric_distribution = NonParametricNORTA.convert_data(y) + +model = auto_arima(transformed_y; seasonal = 12) +fit!(model) +scenarios = simulate_scenarios(model, 24, 100)[:, 1, :] +expected_value = [i[1] for i in forecast(model, 24).expected_value] + +scenarios = NonParametricNORTA.reverse_data(scenarios, non_parametric_distribution) +expected_value = NonParametricNORTA.reverse_data(expected_value, non_parametric_distribution) + +plt = plot(dates, y, label = "Historical Values", color = :black, w=2, legend=:outertop) +plot!(plt, forecast_dates, scenarios, label = "", color = "grey", width = 0.2) +plot!(forecast_dates, expected_value.*NaN, color = "grey", label="Scenarios") +plot!(forecast_dates, expected_value, lab = "Expected Value", color = :red) -plot(y_train, w=2, color = "black", lab = "Original Historic", legend=:outerbottom) -for i in 1:N_scenarios - plot!(vcat(ones(T_train).*NaN, scenarios[:, i]), color = "red", alpha = 0.2, lab = "") -end -plot!([], color="red", lab = "Scenarios") ``` -![simulation](./docs/figures/simulation.PNG) +![norta_simulation](./docs/figures/inflow_norta_simulation.PNG) -However, upon reverse transforming the scenarios, we observe that the simulation respects the historical boundaries. This demonstrates the utility of the reverse transformation process in maintaining data integrity within the historical context. +We can see that using the NORTA transformation the simulation respects the historical boundaries. diff --git a/datasets/inflows.csv b/datasets/inflows.csv new file mode 100644 index 0000000..3008f48 --- /dev/null +++ b/datasets/inflows.csv @@ -0,0 +1,301 @@ +Date,MW +1990-01-01,57492.0 +1990-02-01,60841.0 +1990-03-01,53980.0 +1990-04-01,36202.0 +1990-05-01,28100.0 +1990-06-01,23593.0 +1990-07-01,21316.0 +1990-08-01,25463.0 +1990-09-01,26246.0 +1990-10-01,20358.0 +1990-11-01,27336.0 +1990-12-01,62655.0 +1991-01-01,79711.0 +1991-02-01,41397.0 +1991-03-01,43143.0 +1991-04-01,34741.0 +1991-05-01,29663.0 +1991-06-01,23024.0 +1991-07-01,24399.0 +1991-08-01,22020.0 +1991-09-01,25830.0 +1991-10-01,26548.0 +1991-11-01,24366.0 +1991-12-01,25119.0 +1992-01-01,47675.0 +1992-02-01,64956.0 +1992-03-01,67589.0 +1992-04-01,68237.0 +1992-05-01,39812.0 +1992-06-01,29407.0 +1992-07-01,24668.0 +1992-08-01,19672.0 +1992-09-01,17125.0 +1992-10-01,26392.0 +1992-11-01,22818.0 +1992-12-01,35153.0 +1993-01-01,59939.0 +1993-02-01,85850.0 +1993-03-01,55549.0 +1993-04-01,50229.0 +1993-05-01,49954.0 +1993-06-01,34213.0 +1993-07-01,26046.0 +1993-08-01,22294.0 +1993-09-01,27881.0 +1993-10-01,33842.0 +1993-11-01,45942.0 +1993-12-01,53800.0 +1994-01-01,47618.0 +1994-02-01,68043.0 +1994-03-01,55607.0 +1994-04-01,46683.0 +1994-05-01,32297.0 +1994-06-01,31268.0 +1994-07-01,23083.0 +1994-08-01,20688.0 +1994-09-01,23187.0 +1994-10-01,29337.0 +1994-11-01,21151.0 +1994-12-01,35122.0 +1995-01-01,64242.0 +1995-02-01,51156.0 +1995-03-01,60587.0 +1995-04-01,43217.0 +1995-05-01,31965.0 +1995-06-01,28561.0 +1995-07-01,24260.0 +1995-08-01,18859.0 +1995-09-01,15101.0 +1995-10-01,15980.0 +1995-11-01,23728.0 +1995-12-01,36155.0 +1996-01-01,52033.0 +1996-02-01,83089.0 +1996-03-01,51899.0 +1996-04-01,46963.0 +1996-05-01,34553.0 +1996-06-01,24851.0 +1996-07-01,23659.0 +1996-08-01,16810.0 +1996-09-01,15453.0 +1996-10-01,25645.0 +1996-11-01,25113.0 +1996-12-01,33841.0 +1997-01-01,54705.0 +1997-02-01,40757.0 +1997-03-01,53675.0 +1997-04-01,36294.0 +1997-05-01,26398.0 +1997-06-01,20891.0 +1997-07-01,18138.0 +1997-08-01,15966.0 +1997-09-01,21040.0 +1997-10-01,21942.0 +1997-11-01,36214.0 +1997-12-01,45654.0 +1998-01-01,91733.0 +1998-02-01,72623.0 +1998-03-01,57340.0 +1998-04-01,44941.0 +1998-05-01,32515.0 +1998-06-01,39236.0 +1998-07-01,28081.0 +1998-08-01,21218.0 +1998-09-01,20253.0 +1998-10-01,24862.0 +1998-11-01,33307.0 +1998-12-01,50420.0 +1999-01-01,42917.0 +1999-02-01,53523.0 +1999-03-01,55192.0 +1999-04-01,45015.0 +1999-05-01,34691.0 +1999-06-01,26449.0 +1999-07-01,20732.0 +1999-08-01,22483.0 +1999-09-01,23157.0 +1999-10-01,33401.0 +1999-11-01,28656.0 +1999-12-01,39389.0 +2000-01-01,58172.0 +2000-02-01,50152.0 +2000-03-01,58904.0 +2000-04-01,33859.0 +2000-05-01,25772.0 +2000-06-01,24001.0 +2000-07-01,22141.0 +2000-08-01,15666.0 +2000-09-01,16599.0 +2000-10-01,13760.0 +2000-11-01,19991.0 +2000-12-01,30979.0 +2001-01-01,55086.0 +2001-02-01,67193.0 +2001-03-01,61750.0 +2001-04-01,37938.0 +2001-05-01,24808.0 +2001-06-01,21243.0 +2001-07-01,19637.0 +2001-08-01,18794.0 +2001-09-01,29810.0 +2001-10-01,18570.0 +2001-11-01,29025.0 +2001-12-01,44900.0 +2002-01-01,40408.0 +2002-02-01,40077.0 +2002-03-01,37906.0 +2002-04-01,28635.0 +2002-05-01,22673.0 +2002-06-01,20285.0 +2002-07-01,17172.0 +2002-08-01,14625.0 +2002-09-01,15492.0 +2002-10-01,21866.0 +2002-11-01,25856.0 +2002-12-01,40097.0 +2003-01-01,63205.0 +2003-02-01,70382.0 +2003-03-01,48800.0 +2003-04-01,31251.0 +2003-05-01,28539.0 +2003-06-01,20773.0 +2003-07-01,18110.0 +2003-08-01,16350.0 +2003-09-01,17336.0 +2003-10-01,13128.0 +2003-11-01,22553.0 +2003-12-01,34851.0 +2004-01-01,59676.0 +2004-02-01,61144.0 +2004-03-01,48336.0 +2004-04-01,42433.0 +2004-05-01,26791.0 +2004-06-01,22631.0 +2004-07-01,19317.0 +2004-08-01,15453.0 +2004-09-01,14901.0 +2004-10-01,15661.0 +2004-11-01,21409.0 +2004-12-01,33553.0 +2005-01-01,46920.0 +2005-02-01,70979.0 +2005-03-01,62252.0 +2005-04-01,48041.0 +2005-05-01,37449.0 +2005-06-01,33344.0 +2005-07-01,27521.0 +2005-08-01,19268.0 +2005-09-01,15114.0 +2005-10-01,21647.0 +2005-11-01,25949.0 +2005-12-01,40178.0 +2006-01-01,66456.0 +2006-02-01,58500.0 +2006-03-01,56761.0 +2006-04-01,37543.0 +2006-05-01,31017.0 +2006-06-01,27843.0 +2006-07-01,21228.0 +2006-08-01,16947.0 +2006-09-01,19565.0 +2006-10-01,23056.0 +2006-11-01,28733.0 +2006-12-01,56438.0 +2007-01-01,46497.0 +2007-02-01,48707.0 +2007-03-01,58816.0 +2007-04-01,50040.0 +2007-05-01,29101.0 +2007-06-01,23156.0 +2007-07-01,20355.0 +2007-08-01,17288.0 +2007-09-01,18415.0 +2007-10-01,25962.0 +2007-11-01,28972.0 +2007-12-01,56495.0 +2008-01-01,94605.0 +2008-02-01,90929.0 +2008-03-01,51458.0 +2008-04-01,35442.0 +2008-05-01,29123.0 +2008-06-01,24070.0 +2008-07-01,23365.0 +2008-08-01,18878.0 +2008-09-01,13222.0 +2008-10-01,13424.0 +2008-11-01,23682.0 +2008-12-01,29875.0 +2009-01-01,37972.0 +2009-02-01,63252.0 +2009-03-01,63738.0 +2009-04-01,52206.0 +2009-05-01,36211.0 +2009-06-01,28072.0 +2009-07-01,21178.0 +2009-08-01,22681.0 +2009-09-01,16272.0 +2009-10-01,20869.0 +2009-11-01,26112.0 +2009-12-01,38238.0 +2010-01-01,54583.0 +2010-02-01,65848.0 +2010-03-01,47528.0 +2010-04-01,48871.0 +2010-05-01,31401.0 +2010-06-01,25564.0 +2010-07-01,27969.0 +2010-08-01,24338.0 +2010-09-01,31695.0 +2010-10-01,36870.0 +2010-11-01,37511.0 +2010-12-01,61945.0 +2011-01-01,70653.0 +2011-02-01,59278.0 +2011-03-01,53828.0 +2011-04-01,45650.0 +2011-05-01,29402.0 +2011-06-01,23375.0 +2011-07-01,20568.0 +2011-08-01,15930.0 +2011-09-01,13799.0 +2011-10-01,21837.0 +2011-11-01,29116.0 +2011-12-01,44302.0 +2012-01-01,76036.0 +2012-02-01,49825.0 +2012-03-01,85999.0 +2012-04-01,54975.0 +2012-05-01,33691.0 +2012-06-01,27975.0 +2012-07-01,24232.0 +2012-08-01,23952.0 +2012-09-01,16530.0 +2012-10-01,24899.0 +2012-11-01,27107.0 +2012-12-01,44359.0 +2013-01-01,73094.0 +2013-02-01,49275.0 +2013-03-01,36886.0 +2013-04-01,32008.0 +2013-05-01,29755.0 +2013-06-01,38166.0 +2013-07-01,26257.0 +2013-08-01,17135.0 +2013-09-01,14598.0 +2013-10-01,14999.0 +2013-11-01,23056.0 +2013-12-01,27619.0 +2014-01-01,46596.0 +2014-02-01,56166.0 +2014-03-01,48967.0 +2014-04-01,51081.0 +2014-05-01,29018.0 +2014-06-01,38001.0 +2014-07-01,30589.0 +2014-08-01,18994.0 +2014-09-01,16897.0 +2014-10-01,23751.0 +2014-11-01,22610.0 +2014-12-01,39726.0 diff --git a/docs/figures/inflow_norta_simulation.png b/docs/figures/inflow_norta_simulation.png new file mode 100644 index 0000000..cc911ff Binary files /dev/null and b/docs/figures/inflow_norta_simulation.png differ diff --git a/docs/figures/inflow_simulation.png b/docs/figures/inflow_simulation.png new file mode 100644 index 0000000..ecea53f Binary files /dev/null and b/docs/figures/inflow_simulation.png differ diff --git a/src/NonParametricNORTA.jl b/src/NonParametricNORTA.jl index 9a34283..78c2cc0 100644 --- a/src/NonParametricNORTA.jl +++ b/src/NonParametricNORTA.jl @@ -6,8 +6,10 @@ using Distributions, Interpolations, KernelDensity, Statistics, StatsBase include("transform_data.jl") +export convert_data, reverse_data + """ -convertData(observations::Vector{Fl}) where Fl +convert_data(observations::Vector{Fl}) where Fl Returns the NORTA transformed observations and the non parametric distribution of the observations. @@ -18,13 +20,14 @@ convertData(observations::Vector{Fl}) where Fl - `get_transformed_observations(non_parametric_distribution, observations)`: NORTA transformed observations. - `non_parametric_distribution`: Non parametric distribution of the observations. """ -function convertData(observations::Vector{Fl}) where Fl +function convert_data(observations::Vector{Fl}) where Fl + all(x -> isa(x, Int), observations) ? observations = convert(Vector{Float64}, observations) : nothing non_parametric_distribution = get_discretenonparametric_distribution(observations) return get_transformed_observations(non_parametric_distribution, observations), non_parametric_distribution end """ - reverseData(scenarios::Union{Vector{Fl}, Matrix{Fl}}, non_parametric_distribution::DiscreteNonParametric) where Fl + reverse_data(scenarios::Union{Vector{Fl}, Matrix{Fl}}, non_parametric_distribution::DiscreteNonParametric) where Fl Returns the reverse NORTA transformed scenarios. @@ -35,7 +38,7 @@ end # Returns - `reverse_data(interpolation, normal_cumulative_value, non_parametric_distribution)`: Scenarios data in the original scale. """ -function reverseData(scenarios::Union{Vector{Fl}, Matrix{Fl}}, non_parametric_distribution::DiscreteNonParametric) where Fl +function reverse_data(scenarios::Union{Vector{Fl}, Matrix{Fl}}, non_parametric_distribution::DiscreteNonParametric) where Fl normal_cumulative_value = get_normal_cdf(scenarios) interpolation = get_interpolation_function(normal_cumulative_value, non_parametric_distribution) return reverse_data(interpolation, normal_cumulative_value, non_parametric_distribution) diff --git a/src/transform_data.jl b/src/transform_data.jl index 3c04fa3..fdf8843 100644 --- a/src/transform_data.jl +++ b/src/transform_data.jl @@ -69,7 +69,7 @@ end - `non_parametric_distribution::DiscreteNonParametric`: Non parametric distribution of the observations. # Returns - - `LinearInterpolation(cdf_range, quantile_range) `: interpolation function of the normal cumulative distribution of the scenarios. + - `linear_interpolation(cdf_range, quantile_range) `: interpolation function of the normal cumulative distribution of the scenarios. """ function get_interpolation_function(normal_cumulative_value::Union{Vector{Fl}, Matrix{Fl}}, non_parametric_distribution::DiscreteNonParametric) where Fl @@ -78,7 +78,9 @@ function get_interpolation_function(normal_cumulative_value::Union{Vector{Fl}, M quantile_range = [quantile(non_parametric_distribution, t) for t in cdf_range] - return LinearInterpolation(cdf_range, quantile_range) + Interpolations.deduplicate_knots!(cdf_range) + Interpolations.deduplicate_knots!(quantile_range) + return linear_interpolation(cdf_range, quantile_range) end """ diff --git a/test/NonParametricNORTA.jl b/test/NonParametricNORTA.jl index 107c5e8..ac50365 100644 --- a/test/NonParametricNORTA.jl +++ b/test/NonParametricNORTA.jl @@ -1,25 +1,25 @@ -@testset "Function: convertData" begin +@testset "Function: convert_data" begin observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - expected = NonParametricNORTA.convertData(observations) + expected = NonParametricNORTA.convert_data(observations) @test trunc.(expected[1], digits = 3) == [-1.281, -0.841, -0.524, -0.253, 0.0, 0.253, 0.524, 0.841, 1.281, 4.264] @test expected[2].support == observations @test expected[2].p == ones(10)./10 observations = [1, 1, 1, 1, 1, 3, 2, 2, 2, 2] - expected = NonParametricNORTA.convertData(observations) + expected = NonParametricNORTA.convert_data(observations) @test trunc.(expected[1], digits = 3) == [0, 0, 0, 0, 0, 4.264, 1.281, 1.281, 1.281, 1.281] @test expected[2].support == [1, 2, 3] @test expected[2].p == [0.5, 0.4, 0.1] end -@testset "Function: reverseData" begin +@testset "Function: reverse_data" begin observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - transformed_y, non_parametric_distribution = NonParametricNORTA.convertData(observations) - expected = NonParametricNORTA.reverseData(transformed_y, non_parametric_distribution) + transformed_y, non_parametric_distribution = NonParametricNORTA.convert_data(observations) + expected = NonParametricNORTA.reverse_data(transformed_y, non_parametric_distribution) @test trunc.(expected, digits = 3) == observations observations = collect(-1000:100:1000) - transformed_y, non_parametric_distribution = NonParametricNORTA.convertData(observations) - expected = NonParametricNORTA.reverseData(transformed_y, non_parametric_distribution) + transformed_y, non_parametric_distribution = NonParametricNORTA.convert_data(observations) + expected = NonParametricNORTA.reverse_data(transformed_y, non_parametric_distribution) @test trunc.(expected, digits = 3) == observations end \ No newline at end of file diff --git a/test/transform_data.jl b/test/transform_data.jl index f26e283..6506f9c 100644 --- a/test/transform_data.jl +++ b/test/transform_data.jl @@ -29,14 +29,14 @@ end @testset "Function: get_interpolation_function" begin normal_cumulative_value = NonParametricNORTA.get_normal_cdf([-1.281, -0.841, -0.524, -0.253, 0.0, 0.253, 0.524, 0.841, 1.281, 5.612]) - observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10.0] non_parametric_distribution = NonParametricNORTA.get_discretenonparametric_distribution(observations) expected = NonParametricNORTA.get_interpolation_function(normal_cumulative_value, non_parametric_distribution) @test isa(expected, NonParametricNORTA.Interpolations.Extrapolation) end @testset "Function: reverse_data" begin - observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10.0] non_parametric_distribution = NonParametricNORTA.get_discretenonparametric_distribution(observations) transformed_obs = NonParametricNORTA.get_transformed_observations(non_parametric_distribution, observations) normal_cumulative_value = round.(NonParametricNORTA.get_normal_cdf(transformed_obs), digits = 8) @@ -44,7 +44,7 @@ end expected = NonParametricNORTA.reverse_data(interpolation, normal_cumulative_value, non_parametric_distribution) @test trunc.(expected, digits = 3) == observations - observations = [1, 1, 1, 1, 1, 3, 2, 2, 2, 2] + observations = [1, 1, 1, 1, 1, 3, 2, 2, 2, 2.0] non_parametric_distribution = NonParametricNORTA.get_discretenonparametric_distribution(observations) transformed_obs = NonParametricNORTA.get_transformed_observations(non_parametric_distribution, observations) normal_cumulative_value = round.(NonParametricNORTA.get_normal_cdf(transformed_obs), digits = 8)