Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Vietoris-Rips PH

## censored death values

This version addresses #39 by encoding deaths that exceed the threshold as undefined (`NaN`) rather than infinite (`Inf`) then converting these values to missing (`NA_REAL`) while populating the `Rcpp::NumericMatrix` returned to R.
A single infinite degree-0 feature for the connected component is retained.

### sliding window embeddings of multivariable time series (breaking change)

Previously only univariable time series could be passed to `vietoris_rips()` via the sliding window embedding (used for quasi-attractor detection).
Expand Down
2 changes: 1 addition & 1 deletion R/data.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' acre_coord <- aegypti[aegypti$state_code == "AC", c("x", "y"), drop = FALSE]
#' acre_rips <- vietoris_rips(acre_coord)
#' plot.new()
#' xymax <- max(setdiff(acre_rips$death, Inf))
#' xymax <- max(setdiff(acre_rips$death, Inf), na.rm = TRUE)
#' plot.window(
#' xlim = c(0, xymax),
#' ylim = c(0, xymax),
Expand Down
2 changes: 1 addition & 1 deletion man/aegypti.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions src/ripser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,10 @@ template <typename DistanceMatrix> class ripser {
#endif
// ripserq: Accumulate pairs in an object to be returned to the user.
#ifdef COLLECT_PERSISTENCE_PAIRS
for (index_t i = 0; i < n; ++i)
if (dset.find(i) == i) persistence_pairs[0].emplace_back(0.0, std::numeric_limits<value_t>::infinity());
for (index_t i = 0; i < n - 1; ++i)
// ripserq: `quiet_NaN()` for deaths that subceed threshold.
if (dset.find(i) == i) persistence_pairs[0].emplace_back(0.0, std::numeric_limits<value_t>::quiet_NaN());
if (dset.find(n - 1) == n - 1) persistence_pairs[0].emplace_back(0.0, std::numeric_limits<value_t>::infinity());
#endif
}

Expand Down Expand Up @@ -863,7 +865,8 @@ template <typename DistanceMatrix> class ripser {
#endif
// ripserq: Accumulate pairs in an object to be returned to the user.
#ifdef COLLECT_PERSISTENCE_PAIRS
persistence_pairs[dim].emplace_back(diameter, std::numeric_limits<value_t>::infinity());
// ripserq: `quiet_NaN()` for deaths that subceed threshold.
persistence_pairs[dim].emplace_back(diameter, std::numeric_limits<value_t>::quiet_NaN());
#endif
break;
}
Expand Down Expand Up @@ -1404,7 +1407,10 @@ Rcpp::List ripser_cpp_dist(const Rcpp::NumericVector &dataset, int dim, double t
Rcpp::NumericMatrix mat(pairs.size(), 2);
for (size_t i = 0; i < pairs.size(); ++i) {
mat(i, 0) = pairs[i].first;
mat(i, 1) = pairs[i].second;
if (std::isnan(pairs[i].second))
mat(i, 1) = NA_REAL;
else
mat(i, 1) = pairs[i].second;
}
output[d] = mat;
}
Expand Down