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

  • Home
  • SEARCH
  • 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 9185623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:19:21+00:00 2026-06-17T19:19:21+00:00

Say I have the following example distribution (vector) of numbers in c++: vector 1

  • 0

Say I have the following example distribution (vector) of numbers in c++:

vector 1    vector 2   vector 3
11          4          65
128         6          66
12          4          64
13          4          62
12          5          65
14          5          63
16          7          190
60          3          210
120         4          220
126         5          242
77          6          231
14          4          210
12          7          222
13          6          260
11          8          300
14          6          233
99                     80
15                     66
13

I need to find a threshold for each vector. I’ll eliminate the larger (“bad”) numbers in each if they are above that vector’s threshold. I want to re-use this method to find a threshold on other similar vectors in the future. The numbers aren’t necessarily mostly smaller “good” numbers.

The threshold would ideally be just a hair larger than most of the smaller “good” numbers. For example, the first vetor’s ideal threshold value would be around 17 or 18, the second’s would be about 8, and the third’s would be around 68-70.

I realize this is probably simple math but since I’m horrible at math in general, I would really appreciate a code example on how to find this magical threshold, in either C++ or Objective-C specifically, which is why I’m posting this in SO and not on the Math site.

Some things I’ve tried

float threshold = mean_of_vector;
float threshold = mean_of_vector / 1.5f;
float threshold = ((max_of_vector - min_of_vector) / 2.0f) + mean_of_vector;

Each of these seem to have their own issues, eg: some include too many of the “good” average numbers (so the threshold was too low), some not enough good numbers (threshold too high), or not enough of the “bad” numbers. Sometimes they’ll work with specific vectors of numbers, for example, if the standard deviation is high, but not others where the standard deviation is low.

I’m thinking the method would involve standard deviation and/or some sort of gaussian distribution, but I don’t know how to piece them together to get the desired result.

Edit: I am able to re-sort the vectors.

  • 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-06-17T19:19:22+00:00Added an answer on June 17, 2026 at 7:19 pm

    You could just eliminate the values above 90% or 95%.
    Technicaly you calculate the p = 0.9 (or 0.95) percentile of the array distribution.

    Just sort the array ascending:

    int[] data;
    
    Arrays.sort(data); // or use ArrayList<Integer> which has Collections.sort(dataArrayList),
    

    Then calculate position of percentile p:

    float p = data.length * p; // e.g p = 0.9 for 90% percentile.
    // cut of fractional part.
    int posInt = (int) p;
    
    // this is the threshold value 
    int threshold = data[posInt]
    

    Now filter array by keeping all value < or <= threshold.
    This keeps the 90% of smallest values.

    int i = 0;
    while (i < data.length && data[i] <= threshold) {
      // output data[i];
    }
    

    For mathematically “perfect” results you could search for “calculate percentile of discrete array / values).
    As i remeber there are two valid algorithms, describeing whether one has to round down or round up the posInt. I my example above I just truncated.

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

Sidebar

Related Questions

I do not understand the following example, let's say I have these functions: #
Say I have the following code: <div onclick='location.href=http://www.example.com/'> <a href='#' onclick='alert(blah)'>click</a> </div> Is there
For example, let's say I have the following two tables: Table1: Id ---- 1
Say suppose I have the following Java code. public class Example { public static
Say for example I have the following styles: #HorizNav ul li a.active:link { background-color:
Say for example, I have the following two tables: TableA { _id } TableB
Say I have the following domain: example.com I have a Wildcard SSL certificate for
Say I have the following pattern: INDICATOR\s+([a-z0-9]+) which would match for example: INDICATOR AA
Is this even possible? For example, let's say I have the following: class Window
Let's say I have following code: $file=http://example.com/path/to/file.zip; $in = fopen($file, r); var_dump($in); // result

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.