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

Goodness-of-fit diagnostics for Hawkes EM algorithm #507

Merged
merged 39 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
960dad4
Hawkes EM qq plots - first commit
claudio-tw Jan 9, 2023
461be54
Hawkes EM qq plots - workings
claudio-tw Jan 9, 2023
738f0f8
HawkesEM - Compute time integral of intensities
claudio-tw Jan 10, 2023
1d3be6f
HawkesEM - Time-changed interarrival
claudio-tw Jan 17, 2023
8c31191
debugging
claudio-tw Jan 18, 2023
ae6aba3
Merge branch 'master' into hawkes-em-qqplots
claudio-tw Jan 18, 2023
aaa5770
debugging
claudio-tw Jan 18, 2023
8fbf3dd
debugging
claudio-tw Jan 19, 2023
2f12ab0
Update configure_env.sh and gtest.sh
claudio-tw Jan 20, 2023
79b80fa
HawkesEM gtest - ok till implicit abscissa
claudio-tw Jan 20, 2023
0dac27c
HawkesEM Gtest - pass till data with explicit abscissa
claudio-tw Jan 20, 2023
e73d09c
HawkesEM Gtest - pass till values with explicit abscissa
claudio-tw Jan 20, 2023
fd879c4
HawkesEM - Py unittest of fit method with simulated data
claudio-tw Jan 23, 2023
ea705e8
HawkesEM - test with simulated data
claudio-tw Jan 23, 2023
f674217
HawkesEM - basic unit tests for inter-arrival times
claudio-tw Jan 23, 2023
1c25fce
try get more python working on windows
PhilipDeegan Feb 12, 2023
68394f3
Fix usage of threshold in _index_left and _t_left
claudio-ICL Feb 14, 2023
3f0dc58
Hawkes EM qq plots - first commit
claudio-tw Jan 9, 2023
eeb106c
Hawkes EM qq plots - workings
claudio-tw Jan 9, 2023
e1f16aa
HawkesEM - Compute time integral of intensities
claudio-tw Jan 10, 2023
4c1c209
HawkesEM - Time-changed interarrival
claudio-tw Jan 17, 2023
0879fd8
debugging
claudio-tw Jan 18, 2023
94bf8d0
debugging
claudio-tw Jan 18, 2023
a77691d
debugging
claudio-tw Jan 19, 2023
2ce06f6
Update configure_env.sh and gtest.sh
claudio-tw Jan 20, 2023
a02d2a4
HawkesEM gtest - ok till implicit abscissa
claudio-tw Jan 20, 2023
2f74b34
HawkesEM Gtest - pass till data with explicit abscissa
claudio-tw Jan 20, 2023
93f0ecf
HawkesEM Gtest - pass till values with explicit abscissa
claudio-tw Jan 20, 2023
bbfd681
HawkesEM - Py unittest of fit method with simulated data
claudio-tw Jan 23, 2023
be8a41b
HawkesEM - test with simulated data
claudio-tw Jan 23, 2023
f4fb044
HawkesEM - basic unit tests for inter-arrival times
claudio-tw Jan 23, 2023
dc70cab
Fix usage of threshold in _index_left and _t_left
claudio-ICL Feb 14, 2023
d443aae
Merge 'hawkes-em-qqplots' into hawkes-em-qqplots
claudio-tw Mar 3, 2023
693c65d
Example - QQplot of simulated Hawkes process
claudio-tw Mar 3, 2023
7ea4702
Examples - QQ plot of Hawkes EM algo
claudio-tw Mar 3, 2023
3aca627
TimeFunction - fix future max
claudio-ICL Mar 3, 2023
d67b58b
HawkesEM test - test 3 rtol
claudio-ICL Mar 3, 2023
d5e1bd1
HawkesKernelTiemFunc - get norm using time_func
claudio-ICL Mar 4, 2023
e43af7e
Clean comments in hawkes em test]
claudio-ICL Mar 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/cpp-test/hawkes/inference/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_executable(tick_test_hawkes_inference
hawkes_em_gtest.cpp
)

target_link_libraries(tick_test_hawkes_inference
${TICK_LIB_ARRAY}
${TICK_LIB_BASE}
${TICK_LIB_CRANDOM}
${TICK_LIB_BASE_MODEL}
${TICK_LIB_LINEAR_MODEL}
${TICK_LIB_HAWKES_INFERENCE}
${TICK_LIB_HAWKES_MODEL}
${TICK_TEST_LIBS}
)


49 changes: 49 additions & 0 deletions lib/cpp-test/hawkes/inference/hawkes_em_gtest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// License: BSD 3 clause

#include <gtest/gtest.h>
#include "tick/hawkes/inference/hawkes_em.h"

class HawkesEMTest : public ::testing::Test {
protected:
ulong n_nodes;
double kernel_support;
ulong kernel_size;
ArrayDouble mu;
ArrayDouble2d kernels;
HawkesEM em;
void SetUp() override {
n_nodes = 2;
kernel_support = 1.;
kernel_size = 10;
em = HawkesEM(kernel_support, kernel_size, 1);
mu = ArrayDouble{.05, .05};
kernels = ArrayDouble2d{
{.1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .2, .2, .1, .0, .0, .0, .0, .1, .2, .2},
{.0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .2, .2, .4, .1, .1, .0, .0, .0}};
}
};

TEST_F(HawkesEMTest, get_kernel_size) { EXPECT_EQ(em.get_kernel_size(), kernel_size); }

TEST_F(HawkesEMTest, init_kernel_time_func) {
em.init_kernel_time_func(kernels);
std::vector<TimeFunction>& timefunc = em.get_kernel_time_func();
ArrayDouble kernel_discretization = *em.get_kernel_discretization();
for (ulong u = 0; u < n_nodes; ++u) {
for (ulong v = 0; v < n_nodes; ++v) {
ulong uv = u * n_nodes + v;
for (ulong k = 0; k < kernel_size; ++k) {
ulong vk = v * kernel_size + k;
double t = kernel_discretization[k];
EXPECT_DOUBLE_EQ(timefunc[uv].evaluate(t), kernels(u, vk));
}
}
}
}

#ifdef ADD_MAIN
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
#endif // ADD_MAIN
Loading