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 6991455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:30:16+00:00 2026-05-27T19:30:16+00:00

In analysis of energy demand and consumption data, I’m having issue re-sampling and interpolating

  • 0

In analysis of energy demand and consumption data, I’m having issue re-sampling and interpolating time series trended data.

Data set example:

timestamp                value kWh
------------------       ---------
12/19/2011 5:43:21 PM    79178
12/19/2011 5:58:21 PM    79179.88
12/19/2011 6:13:21 PM    79182.13
12/19/2011 6:28:21 PM    79183.88
12/19/2011 6:43:21 PM    79185.63

Based upon these observations, I’d like some aggregation to roll-up values based upon a period of time, with that frequency set to a unit of time.

As in, intervals on the hour filling any gaps of missing data

timestamp                value (approx)
------------------       ---------
12/19/2011 5:00:00 PM    79173
12/19/2011 6:00:00 PM    79179
12/19/2011 7:00:00 PM    79186

For a linear algorithm, it seems I would take the difference in time and multiply the value against that factor.

TimeSpan ts = current - previous;

Double factor = ts.TotalMinutes / period;

Value and timestamp could be calculated based upon the factor.

With such quantity of available information, I’m unsure why it’s difficult to find the most elegant approach to this.

Perhaps first, are there open source analysis libraries that could be recommended?

Any recommendations for a programmatic approach? Ideally C#, or possibly with SQL?

Or, any similar questions (with answers) I could be pointed to?

  • 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-27T19:30:17+00:00Added an answer on May 27, 2026 at 7:30 pm

    By using the time-ticks that are used internally to represent DateTimes, you get the most accurate values that are possible. Since these time ticks do not restart at zero at midnight, you will not have problems at day boundaries.

    // Sample times and full hour
    DateTime lastSampleTimeBeforeFullHour = new DateTime(2011, 12, 19, 17, 58, 21);
    DateTime firstSampleTimeAfterFullHour = new DateTime(2011, 12, 19, 18, 13, 21);
    DateTime fullHour = new DateTime(2011, 12, 19, 18, 00, 00);
    
    // Times as ticks (most accurate time unit)
    long t0 = lastSampleTimeBeforeFullHour.Ticks;
    long t1 = firstSampleTimeAfterFullHour.Ticks;
    long tf = fullHour.Ticks;
    
    // Energy samples
    double e0 = 79179.88; // kWh before full hour
    double e1 = 79182.13; // kWh after full hour
    double ef; // interpolated energy at full hour
    
    ef = e0 + (tf - t0) * (e1 - e0) / (t1 - t0); // ==> 79180.1275 kWh
    

    Explanation of the formula
    In geometry, similar triangles are triangles that have the same shape but different sizes. The formula above is based on the fact that the ratios of any two sides in one triangle are the same for the corresponding sides of a similar triangle.

    If you have a triangle A B C and a similar triangle a b c, then A : B = a : b. The equality of two ratios is called a proportion.

    We can apply this proportionality rule to our problem:

    (e1 – e0) / (t1 – t0) = (ef – e0) / (tf – t0)
    --- large triangle --   --- small triangle --
    

    enter image description here

    We can multiply both sides of the equation above by (tf – t0):

    (tf – t0) * (e1 – e0) / (t1 – t0) = (ef – e0)

    By adding e0 on both sides we can isolate ef:

    e0 + (tf – t0) * (e1 – e0) / (t1 – t0) = ef

    Let’s swap the two sides:

    ef = e0 + (tf – t0) * (e1 – e0) / (t1 – t0)

    That’s it. The way we calculated the intermediate value is called "linear interpolation".

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

Sidebar

Related Questions

I have some data analysis code that processes an input file and outputs HTML
I've got some analysis code ( myprog ) that sucks in data using the
I am learning algorithm analysis. I am having trouble understanding the difference between O,
There exist static analysis tools for Python , but compile time checks tend to
I have a data-analysis question, that I could easily solve with some T-SQL or
I have data analysis application and I need to be able to export database
The average-case analysis is quite hard to do for disjoint data structure. The least
Dependency analysis programs help us organize code by controlling the dependencies between modules in
An analysis from a colleague with UML diagrams contains the following: 0..° I'm familiar
What code analysis tools do you use on your Java projects? I am interested

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.