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

The Archive Base Latest Questions

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

Assume we’re frequently sampling a particular value and want to keep statistics on the

  • 0

Assume we’re frequently sampling a particular value and want to keep statistics on the samples. The simplest approach is to store every sample so we can calculate whatever stats we want, but this requires unbounded storage. Using a constant amount of storage, we can keep track of some stats like minimum and maximum values. What else can we track using only constant storage? I am thinking of percentiles, standard deviation, and any other useful statistics.

That’s the theoretical question. In my actual situation, the samples are simply millisecond timings: profiling information for a long-running application. There will be millions of samples but not much more than a billion or so. So what stats can be kept for the samples using no more than, say, 10 variables?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T14:23:08+00:00Added an answer on May 11, 2026 at 2:23 pm

    Minimum, maximum, average, total count, variance are all easy and useful. That’s 5 values. Usually you’ll store sum and not average, and when you need the average you can just divide the sum by the count.

    So, in your loop

    maxVal=max(x, maxVal); minVal=min(x, minVal); count+=1; sum+=x; secondorder+=x*x; 

    later, you may print any of these stats. Mean and standard deviation can be computed at any time and are:

    mean=sum/count; std=sqrt(secondorder/count - mean*mean); 

    Median and percentile estimation are more difficult, but possible. The usual trick is to make a set of histogram bins and fill the bins when a sample is found inside them. You can then estimate median and such by looking at the distribution of those bin populations. This is only an approximation to the distribution, but often enough. To find the exact median, you must store all samples.

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

Sidebar

Related Questions

Assume I have an enumerable object enum and now I want to get the
Assume I have an image uploaded to a store on Shopify called 'logo.png'. In
Assume that we want to intercept the exit system call and print a message
Assume I have an array: $elements = array('foo', 'bar', 'tar', 'dar'); Then I want
Assume I want to unit test a method with this signature: List<MyItem> getMyItems(); Assume
Assume a table structure of MyTable(KEY, datafield1, datafield2...) . Often I want to either
Assume that we have N erlang nodes, running same application. I want to share
Assume I have a class foo, and wish to use a std::map to store
Assume my string is http://www.test.com\r\nhttp://www.hello.com<some text here>http://www.world.com I want to extract all URLs in
Assume the original picture is 500px in height,400 px in width .I want to

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.