-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from LAMPSPUC/change_package_name
Change package name
- Loading branch information
Showing
6 changed files
with
39 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "NORTA" | ||
name = "NonParametricNORTA" | ||
uuid = "e97a57fc-2266-4ea9-80d8-a1f12fb1471b" | ||
authors = ["andreramosfc <[email protected]>"] | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
|
||
[deps] | ||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module NORTA | ||
module NonParametricNORTA | ||
|
||
const ROBUST_ROUND = 1e-5 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
@testset "Function: convertData" begin | ||
observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
expected = NORTA.convertData(observations) | ||
expected = NonParametricNORTA.convertData(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 = NORTA.convertData(observations) | ||
expected = NonParametricNORTA.convertData(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 | ||
observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
transformed_y, non_parametric_distribution = NORTA.convertData(observations) | ||
expected = NORTA.reverseData(transformed_y, non_parametric_distribution) | ||
transformed_y, non_parametric_distribution = NonParametricNORTA.convertData(observations) | ||
expected = NonParametricNORTA.reverseData(transformed_y, non_parametric_distribution) | ||
@test trunc.(expected, digits = 3) == observations | ||
|
||
observations = collect(-1000:100:1000) | ||
transformed_y, non_parametric_distribution = NORTA.convertData(observations) | ||
expected = NORTA.reverseData(transformed_y, non_parametric_distribution) | ||
transformed_y, non_parametric_distribution = NonParametricNORTA.convertData(observations) | ||
expected = NonParametricNORTA.reverseData(transformed_y, non_parametric_distribution) | ||
@test trunc.(expected, digits = 3) == observations | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using NORTA, Test | ||
using NonParametricNORTA, Test | ||
|
||
include("NORTA.jl") | ||
include("NonParametricNORTA.jl") | ||
include("transform_data.jl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
@testset "Function: get_discretenonparametric_distribution" begin | ||
observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
expected = NORTA.get_discretenonparametric_distribution(observations) | ||
expected = NonParametricNORTA.get_discretenonparametric_distribution(observations) | ||
@test expected.support == observations | ||
@test expected.p == ones(10)./10 | ||
|
||
observations = [1, 1, 1, 1, 1, 3, 2, 2, 2, 2] | ||
expected = NORTA.get_discretenonparametric_distribution(observations) | ||
expected = NonParametricNORTA.get_discretenonparametric_distribution(observations) | ||
@test expected.support == [1, 2, 3] | ||
@test expected.p == [0.5, 0.4, 0.1] | ||
end | ||
|
||
@testset "Function: get_transformed_observations" begin | ||
observations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
non_parametric_distribution = NORTA.get_discretenonparametric_distribution(observations) | ||
expected = NORTA.get_transformed_observations(non_parametric_distribution, observations) | ||
non_parametric_distribution = NonParametricNORTA.get_discretenonparametric_distribution(observations) | ||
expected = NonParametricNORTA.get_transformed_observations(non_parametric_distribution, observations) | ||
@test trunc.(expected, digits = 3) == [-1.281, -0.841, -0.524, -0.253, 0.0, 0.253, 0.524, 0.841, 1.281, 4.264] | ||
end | ||
|
||
@testset "Function: get_normal_cdf" begin | ||
scenarios = [-1.281, -0.841, -0.524, -0.253, 0.0, 0.253, 0.524, 0.841, 1.281, 5.612] | ||
expected = NORTA.get_normal_cdf(scenarios) | ||
expected = NonParametricNORTA.get_normal_cdf(scenarios) | ||
@test round.(expected, digits = 1) == collect(0.1:0.1:1.0) | ||
|
||
scenarios = [1 2 3; 4 5 6] | ||
expected = NORTA.get_normal_cdf(scenarios) | ||
expected = NonParametricNORTA.get_normal_cdf(scenarios) | ||
@test round.(expected, digits = 3) == [0.841 0.977 0.999; 1.0 1.0 1.0] | ||
end | ||
|
||
@testset "Function: get_interpolation_function" begin | ||
normal_cumulative_value = NORTA.get_normal_cdf([-1.281, -0.841, -0.524, -0.253, 0.0, 0.253, 0.524, 0.841, 1.281, 5.612]) | ||
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] | ||
non_parametric_distribution = NORTA.get_discretenonparametric_distribution(observations) | ||
expected = NORTA.get_interpolation_function(normal_cumulative_value, non_parametric_distribution) | ||
@test isa(expected, NORTA.Interpolations.Extrapolation) | ||
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] | ||
non_parametric_distribution = NORTA.get_discretenonparametric_distribution(observations) | ||
transformed_obs = NORTA.get_transformed_observations(non_parametric_distribution, observations) | ||
normal_cumulative_value = round.(NORTA.get_normal_cdf(transformed_obs), digits = 8) | ||
interpolation = NORTA.get_interpolation_function(normal_cumulative_value, non_parametric_distribution) | ||
expected = NORTA.reverse_data(interpolation, normal_cumulative_value, non_parametric_distribution) | ||
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) | ||
interpolation = NonParametricNORTA.get_interpolation_function(normal_cumulative_value, non_parametric_distribution) | ||
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] | ||
non_parametric_distribution = NORTA.get_discretenonparametric_distribution(observations) | ||
transformed_obs = NORTA.get_transformed_observations(non_parametric_distribution, observations) | ||
normal_cumulative_value = round.(NORTA.get_normal_cdf(transformed_obs), digits = 8) | ||
interpolation = NORTA.get_interpolation_function(normal_cumulative_value, non_parametric_distribution) | ||
expected = NORTA.reverse_data(interpolation, normal_cumulative_value, non_parametric_distribution) | ||
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) | ||
interpolation = NonParametricNORTA.get_interpolation_function(normal_cumulative_value, non_parametric_distribution) | ||
expected = NonParametricNORTA.reverse_data(interpolation, normal_cumulative_value, non_parametric_distribution) | ||
@test trunc.(expected, digits = 3) == observations | ||
end |