Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:22:37+00:00 2026-05-23T14:22:37+00:00

I have some measuring data sampled over time and want to integrate it, the

  • 0

I have some measuring data sampled over time and want to integrate it, the test dataset contains ~100000 samples (~100s, 1000Hz) of data.

My first approach was (table contains the timestamp (0..100s) and the value of each data point (both doubles))

# test dataset available (gzipped, 720k) here: http://tux4u.de/so.rtab.gz
table <- read.table("/tmp/so.rtab", header=TRUE)
time <- table$t
data <- table$val
start <- min(time)
stop <- max(time)
sampling_rate <- 1000
divs <- (max(time) - min(time)) * sampling_rate
data_fun <- approxfun(time, data, method="linear", 0, 0)
result <- integrate(data_fun, start, stop, subdivisions=divs)

but somehow the integration runs forever (like an endless loop and eats up one CPU completely). So I looked at the values:

> start
[1] 0
> stop
[1] 98.99908
> divs
[1] 98999.08

The strange thing is that when I evaluate

> integrate(data_fun, 0, 98, subdivisions=100000)$value + integrate(data_fun, 98, 99)$value
[1] 2.640055

it works (computation time <3s) but the following evaluation (should be the same)

> integrate(data_fun, 0, 99, subdivisions=100000)$value

never terminates, too. And even this one (which is in fact a SUBintegral of the one working above) does NOT terminate:

> integrate(data_fun, 0, 89, subdivisions=100000)$value

It seems a bit random to me when it works and when it doesn’t. Am I doing anything wrong or could I improve the process somehow?

Thanks!

(HINT: the sampling points are not necessarily distributed equally)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:22:38+00:00Added an answer on May 23, 2026 at 2:22 pm

    Ekhem, you know that you may just sum it up? cumsum will do this fast:

    cumsum(table$val)*diff(table$t)[1]
    

    For unequal differences, you may use:

    cumsum(table$val[-nrow(table)]*diff(table$t))
    

    There is no need of more complex numerics since the data in this case is very densly sampled; nevertheless there will be always better methods than going through interpolator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some kind of test data and want to create a unit test
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
Due to testing and time measuring I have to write some kind of log
We have some input data that sometimes appears with &nbsp characters on the end.
I have a problem with time measuring that's really bothering me. I am executing
I want to do some performance measuring of a particular method, but I'd like
I have an iPhone app which contains around 80 PNG format images measuring 300x300
I am new to BI/Datawarehousing, and after building some easy samples, I have the
I have some mechanics to measure method execution time. Simply at start of method
I have some UI in VB 2005 that looks great in XP Style, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.