diff --git a/README.md b/README.md index 137138499..fc5c5759d 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This is a C++ statistical library that provides an interface similar to Pandas package in Python.
A DataFrame can have one index column and many data columns of any built-in or user-defined type.
You could slice the data in many different ways. You could join, merge, group-by the data. You could run various statistical, summarization and ML algorithms on the data. You could add your custom algorithms easily. You could multi-column sort, custom pick and delete the data. And more …
+DataFrame also includes a large collection of analytical routines in form of visitors -- see documentation below. These are from basic stats such as Mean, Std Deviation, Return, … to more involved analysis such as Affinity Propagation, Polynomial Fit, Hurst Exponent, … -- See documentation below for a complete list with code samples, and how you can add your custom algorithms.
I have followed a few principles in this library:
diff --git a/docs/HTML/DataFrame.html b/docs/HTML/DataFrame.html index d1647ab11..34bdb7f8d 100644 --- a/docs/HTML/DataFrame.html +++ b/docs/HTML/DataFrame.html @@ -488,7 +488,7 @@

Table of Features (with Code Samples)

set_lock( ) - + struct HurstExponentVisitor{ } diff --git a/docs/HTML/HurstExponentVisitor.html b/docs/HTML/HurstExponentVisitor.html new file mode 100644 index 000000000..762d7e6de --- /dev/null +++ b/docs/HTML/HurstExponentVisitor.html @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + +
Signature Description Parameters
+

+template<typename T,
+         typename I = unsigned long,
+         typename =
+             typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
+struct HurstExponentVisitor;
+        
+
+ This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_action_visit() interface.
+ This functor calculates the Hurst exponent for the given column.
+ A hurst exponent, H, between 0 to 0.5 is said to correspond to a mean reverting process (anti-persistent), H=0.5 corresponds to Geometric Brownian Motion (Random Walk), while H >= 0.5 corresponds to a process which is trending (persistent).

+ explicit HurstExponentVisitor(std::vector<size_t> &&ranges)
+ ranges is a vector of column length divisors. For example, {1, 2, 4 } means calculate Hurst exponent in 3 steps. It divides the time-series column to 1 chunk, 2 chunks and 4 chunks. +
+ T: Column data type.
+ I: Index type. +
+ +
static void test_HurstExponentVisitor()  {
+
+    std::cout << "\nTesting HurstExponentVisitor{ } ..." << std::endl;
+
+    RandGenParams<double>   p;
+
+    p.seed = 123;
+    p.min_value = 0;
+    p.max_value = 30;
+
+    std::vector<double> d1 = gen_uniform_real_dist<double>(1024, p);
+    std::vector<double> d2 = { 0.04, 0.02, 0.05, 0.08, 0.02, -0.17, 0.05, 0.0 };
+    std::vector<double> d3 = { 0.04, 0.05, 0.055, 0.06, 0.061, 0.072, 0.073, 0.8 };
+
+    MyDataFrame df;
+
+    df.load_index(std::move(MyDataFrame::gen_sequence_index(0, 1024, 1)));
+    df.load_column("d1_col", std::move(d1), nan_policy::dont_pad_with_nans);
+    df.load_column("d2_col", std::move(d2), nan_policy::dont_pad_with_nans);
+    df.load_column("d3_col", std::move(d3), nan_policy::dont_pad_with_nans);
+
+    HurstExponentVisitor<double>    he_v1 ({ 1, 2, 4 });
+    auto                            result1 = df.single_act_visit<double>("d2_col", he_v1).get_result();
+
+    assert(result1 - 0.865926 < 0.00001);
+
+    HurstExponentVisitor<double>    he_v2 ({ 1, 2, 4, 5, 6, 7 });
+    auto                            result2 = df.single_act_visit<double>("d1_col", he_v2).get_result();
+
+    assert(result2 - 0.487977 < 0.00001);
+
+    HurstExponentVisitor<double>    he_v3 ({ 1, 2, 4 });
+    auto                            result3 = df.single_act_visit<double>("d3_col", he_v3).get_result();
+
+    assert(result3 - 0.903057 < 0.00001);
+}
+
+ + + + + +