Comments (13)
Well, probably it would be best not to need any integer representation (i.e., inheritance instead of conditional expressions) What are the current use cases where these integers are needed?
from vinecopulib.
The most important use case is to specify the set of families allowed for selection (this is something user's will do regularly). I think it's just more convenient to write {0, 1, 2, 3, 4, 5}
instead of {Independence, Gaussian, Student, Clayton, Gumbel, Frank}
(using an enum
). We could also allow for both versions.
from vinecopulib.
I would still strongly vote for designing the API in a way that does not feature any integers/flags/enums. What about something like the skeleton below (excuse me if I'm missing some key point!):
#include <list>
#include <memory>
using namespace std;
struct copula_base
{
virtual void magic() const = 0;
};
using ptr = unique_ptr<copula_base>;
struct copula_a : copula_base
{
void magic() const {}
};
struct copula_b : copula_base
{
void magic() const {}
};
void select(list<ptr> &copulae)
{
for (auto &copula : copulae) copula->magic();
}
int main()
{
select({
ptr{new copula_a()},
ptr{new copula_b()}
});
}
from vinecopulib.
The key point is convenience for the user ;) But additionally, your version requires the family to be known at compile time, which isn't always the case.
Even if we keep the C++ library without any integers/enums, we will should introduce them for the R interface, because the average R user knows nothing about classes and inheritance (don't know about python). So we would need a wrapper that converts numbers to the inheritance style in any case (which is exactly what Bicop::create()
does currently).
from vinecopulib.
Well, the user does not need to know anything about inheritance, my point is doing:
select({ptr{new copula_a()}, ptr{new copula_b()} });
instead of
select({44, 666});
The above is about the user perspective, but the actual goal would be not to have any conditional or switch statements in the library (if needed, they could indeed to to the R bindings; Python will certainly be fine with an class-based interface).
Concerning the compile-time requirement, IIUC this is merely the question of having the conditional/switch logic within the library or within the client code.
from vinecopulib.
OK, I think this would be feasible. In R we would certainly still use numbers. For python we should ask chris what he thinks is more convenient/accessible for the average python user (inheritance is also possible in R, but 90% of users would shy away from such a library).
from vinecopulib.
I personally like the integer representation. Additionally to the user friendliness, it's very convenient in the code.
from vinecopulib.
The initial question remains: how should we enumerate the families?
from vinecopulib.
I feel so comfortable working with the VineCopula
encoding that I would be inclined in keeping 0 <= family_
<= 10 as it is just by laziness. I personally like the idea of taking the smallest free integer whenever we implement a new family, but we should probably separate parametric and nonparametric copulas.
If you think that more structure is something we need, then I would argue in favor of an enumeration that uses either the class structure of the library or a category structure (rather than the specific parametrization as you suggested).
For instance:
- family_ = 0 : independence
- 1 < family_ < 50 : parametric
- 1 < family_ < 10 : elliptical
- 11 < family_ < 20 : archimedean
- 21 < family_ < 30 : extreme-value
- 31 < family_ < 40 : other
- 51 <= family_ < 99 : nonparametric
from vinecopulib.
I don't like taking the next free integer at all. The category structure I like, although we'll need to think of how many families we have to reserve in each category (archimedean will need more than 10).
from vinecopulib.
One more think to take into account is probably serialisation of the vine structure - e.g. to handle save/restore functionality
from vinecopulib.
So we're going to abandon numbers and use enum class
after all. Save/restore functionality is still an open issue.
from vinecopulib.
Since we decided to abandon numbers and use enum class
, I'm closing the issue.
from vinecopulib.
Related Issues (20)
- Documentation of the tools_stats namespace HOT 3
- Improved structure selection HOT 5
- Update ThreadPool to latest RcppThread fixes HOT 1
- `str` method for `FitControlsBicop` and `FitControlsVinecop` HOT 1
- Bug in `RVineStructure::simulate()` HOT 1
- New families: rotation mixtures HOT 1
- error for TLL with comonotonic data HOT 1
- AIC as default selection criterion HOT 2
- Add support to save model using optimized data formats HOT 11
- Remove unnecessary whitespace characters in JSON files HOT 2
- High memory usage when loading JSON files HOT 4
- Estimate time of fit/simulate HOT 3
- Miscellaneous addition to docs
- inverse_rosenblatt not using multiple threads when simulating large samples? HOT 2
- gh action script needs update
- about the CDF of the kernel vinecopula HOT 1
- Error msg:Undefined symbols for architecture arm64.
- Compile problem on MacOS: Undefined symbols for architecture arm64 HOT 12
- Enable additional parallelism? HOT 8
- Independence copula causes deserialization to fail HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vinecopulib.