Giter Club home page Giter Club logo

p-var's Introduction

P-var

Efficient computation of p-variation in metric spaces.

Let p≥1. For a discrete time path X0,...,XN in a metric space with distance d, its p-variation is

sup Σk d(Xnk, Xnk-1)p,

where the supremum is taken over all increasing subsequences nk of 0,...,N. Sometimes one takes p-th root of the sum, but here we don't.

There is a very efficient algorithm of computing p-variation for real-valued processes, see paper by Vygantas Butkus and Rimas Norvaiša. But it does not work for example in R2. Here we rectify this, at least partially. We provide a short C++ function which computes p-variation in a general metric space, and is sufficiently fast for paths with millions of points.

In addition, we improve the speed of the one-dimensional algorithm by a factor of 2 to 3.

Usage

Below is a minimal working example. Details and important notes are in p_var.h.

#include <iostream>
#include <vector>
#include <array>

// p_var is a one file header-only library
#include "p_var.h"
using p_var_ns::p_var;

// define a type for data points, in this case R^2
typedef std::array<double, 2> vecR2;

// define a distance function, here L^1
double dist(vecR2 a, vecR2 b) {
	return std::abs(b[0]-a[0]) + std::abs(b[1]-a[1]);
}

int main () {
	// create a path
	std::vector<vecR2> path({{0,0}, {1,1}});

	auto pv = p_var(path, 3, dist);
	// pv.value is the p-variation, and
	// pv.points is vector<size_t> with the maximising subsequence

	std::cout << "3-variation wrt L^1 distance: " << pv.value << std::endl;
	std::cout << "3-variation wrt Euclidean distance: " << p_var(path, 3).value << std::endl;

	return 0;
}

Limitations

Our method is fast on data such as simulated Brownian paths, with complexity of perhaps N log(N). But its worst case complexity is N2. This happens in pathological situations such as monotone paths in R. The one-dimensional method works with such paths much faster.

Authors and contributors (in alphabetic order)

  • Alexey Korepanov
  • Terry Lyons
  • Pavel Zorin-Kranich

p-var's People

Contributors

khumarahn avatar terrylyons avatar pzorin avatar ntapiam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.