Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing hard-coded parametric distribution quantities #22

Open
vincenzocoia opened this issue Nov 20, 2021 · 2 comments
Open

Testing hard-coded parametric distribution quantities #22

vincenzocoia opened this issue Nov 20, 2021 · 2 comments

Comments

@vincenzocoia
Copy link
Collaborator

There are two things we need to test for our parametric distributions (taken from #9)

Testing quantities

We will next need to check that the formulas were inputted correctly. We can automate this. If you have time and are up for a challenge, give this a try.

The idea is to check each quantity against its manual calculation using the distributional representations (like quantile function, cdf, etc.).

I'm thinking something like this:

  1. Loop along each distribution in .quantities.

  2. Get the "formula version" of the quantity, by executing the function directly on an example distribution (such as mu1 <- mean(distribution))

  3. Calculate each quantity present for that distribution using the distributional representations, by accessing the .dst method. So, mu2 <- mean.dst(distribution).

  4. Compare the two: expect_equal(mu1, mu2). Hopefully numerical precision isn't a problem here.

Testing manually coded distributions, like GPD and GEV

For distributions that we had to code manually, like the GPD and GEV, we should also check that the representations are coded correctly. So, if we coded the cdf, density, and quantile function, we could do this by:

  1. calculate numerical derivative of the cdf at a bunch of points, and compare against the density (shows that cdf and density align);
  2. check that eval_cdf(distribution, eval_quantile(distribution, 1:9/10)) returns 1:9/10 (shows that cdf and quantile function align); and
  3. check that the density integrates to 1 (shows that the distribution itself is valid).
@zhuzp98
Copy link
Collaborator

zhuzp98 commented Feb 4, 2022

Update: looped the distributions in test-quantile and marked the descriptions for test results.
For some distributions, even though the test results have some warnings or failures, the primary functions (such as mean, variance, skewness instead of .dst) are correct due to the properties of the distributions themselves.
For example, the Cauchy distribution, whose mean/var/skewness/kurtosis does not exist, the test gives a failure result due to the integral issues from .dst functions. As we are sure that the primary mean, var, skewness, and kurtosis functions are correct, it is unnecessary to care about the test failures of such distributions.

Hence, now we may be able to narrow down the range of distributions and their corresponding functions that need fixing.

@zhuzp98
Copy link
Collaborator

zhuzp98 commented Feb 14, 2022

Update 2: Most of the errors or failures reported in test-quantiles are issues of .dst functions. We may need to pay attention to the kurtosis of weibull. Otherwise should be fine right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants