Finding an anomaly in a set of numbers

Hi,
I am trying to find an anomaly in a set of numbers. However, I'm struggling to implement it. Let's say I have the following numbers:
1
2
3
2
1
5
1
The number five would be the anomaly in this case.
How would I be able to find this with a piece of java code?
Thanks

It is not homework. I am creating a peer assisted study portal. This is where students can submit work and other people can mark it. I was first thinking of counting the occurrences of each rating and then putting them in order and flag the lowest occurrences. When I put that into practise it didn't really work. The other option I tried was the following:
for(int i = 0;i < originalResponses.size(); i++)
            int iValue = Integer.parseInt(originalResponses.get(i).toString());
            iValue = iValue + 2;
            if(iValue > 5)
                iValue = 5;
            for(int a = 0; a < originalResponses.size(); a++)
                int aValue = Integer.parseInt(originalResponses.get(a).toString());
                System.err.println("aValue: " + aValue + " iValue: " + iValue);
                if(aValue < iValue)
                    System.err.println(aValue + " is an anomaly");
        }The problem this threw was that lets say I have the following ratings in the database:
5
1
1
1
1
It would recognise that 5 is an anomaly but it would also recognise that 1 is an anomaly as it is comparing all numbers in all possible combinations.

Similar Messages

  • The "always allow" button is grayed out in settings regarding cookies, and I can not find where to change the setting.  (Restrictions are not on.)

    The "always allow" button is grayed out in settings regarding cookies, and I can not find where to change the setting.  (Restrictions are not on.)  Do you know where I go to change the setting to allow me to "always allow" cookies?

    Hi lisaarnett111,
    If you are having issues turning on Always Allow for cookies in Safari on your iPad, you may want to check to make sure that you don't have Private Browsing enabled, as noted in the following article:
    Turn Private Browsing on or off on your iPhone, iPad, or iPod touch - Apple Support
    Regards,
    - Brenden

  • How to set page numbers in scripts

    Hi,
        i want page numbers at bottom of page,
      please tell me how to set page numbers in scripts?

    Hi,
    In footer
    use this
    &PAGE& / &SAPSCRIPT-FORMPAGES&
    &PAGE& of &SAPSCRIPT-FORMPAGES&
    reward if it helps..
    regards,
    Omkar.

  • How to find out the save as setting information in illustrator cs3?

    How to find out the save as setting information in illustrator cs3 through programmatically. I saved the file using the setting like Overprint, EmbedAllFonts, IncludeDocumentThumbnails throgh scripting. But i don't know how to find out the save as setting information(Overprint, EmbedAllFonts, IncludeDocumentThumbnails) whether the checkbox true or not through scripting. Kindly advice me.

    Thanks for your response. Some time the operator will set the wrong "save as setting" in the eps file . So i need to check wheather the operator set the correct save as setting or not. If the operator set the wrong save as setting,  i need to inform while running the script. So please advice me how to find out the save as setting information of the active document file, and then inform to the operator if any improper "save as setting" occured.

  • My Iphone is disabled and I plugged it into Itunes to restore it but it's saying that I can't do it without turning off "Find My Phone" in my setting, but obviously I can't get into my phone. What do I do?

    My Iphone is disabled and I plugged it into Itunes to restore it but it's saying that I can't do it without turning off "Find My Phone" in my setting, but obviously I can't get into my phone. What do I do?

    www.cloud.com

  • Unable to find specied column in result set.

    i m trying to display database values in textboxes on SelectedIndex_Changed event of list box control but i am getting "Unable to find specified column in result set" again n again..
    why this is so??????

    i have to create a new iview from the template of mdm iviews. then i was asked about the alias property.
    thanks,
    raghavendra

  • HT1212 Someone else has put a password on my phone. I have read all the restoring or backing up methods but when I go to do those it says to turn off find my iPhone in my setting. If I cant unlock my phone I obviously can't turn this off. Help

    Someone else has put a password on my phone. I have read all the restoring or backing up methods but when I go to do those it says to turn off find my iPhone in my setting. If I cant unlock my phone I obviously can't turn this off. Help

    If you have a lock code, how did someone change the apple ID for "find my phone?"   You should go by the apple store and let them help you.

  • Ipad not finding my location, all location setting are on?

    Ipad not finding my location, all location setting are on?

    If you have the WiFi-only iPad your location is determined by the location of nearby WiFi routers. The WiFi-only iPad does not have GPS. Without GPS location-finding is done by using a Apple location database which contains the MAC addresses of routers and their physical location. A MAC address is a unique number which is built-in to all network devices when manufactured. The Apple database is built and updated by Apple GPS-enabled devices (primarily iPhones) actually seeing your router and then adding/updating the router's location in the database.
    Bottom line: Your Router's location is set as the location of your home in the Apple location database. Therefore, no matter where you go, if the router location services sees is your router, it will report your location as your home.

  • Find first record in a set of record

    I want to find first record in a set of record .What built in function shall i use and which trigger should I use.Please help.

    Hi,
    First_record takes you to the position of that first record, but doesn't gives you the value of the record, you have to get it form the :block_name.item_name
    Jose.

  • How do I cerate an array with a set of numbers lets say 1 through 12 random order but no repeating.

    How do I cerate  an
    array with a set of numbers lets say 1 through 12 random order but no
    repeating.
    I know this should be easy but my brain wont work
    right now
    Solved!
    Go to Solution.

    OK, here's the handmade version.
    It is useful to know that arrays of clusters are sorted by the cluster order of the elements. Simply bundle random numbers with numbers 1-12 in a loop, create an array at the output tunnel, sort the array by the random number, and extract the number array. It will be shuffled.
    Message Edited by altenbach on 06-04-2007 09:20 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    shuffleArray.png ‏5 KB

  • ITunes 11.1.4 (62) can't find the info button to set up sync for contacts, calendars, etc.

    I'm running iTunes 11.1.4 (62) and can't find the info button to set up sync for contacts, calendars, etc.

    That option has been removed with Mavericks. Syncing for calendars and contacts etc can only be done through iCloud:
    https://www.apple.com/au/support/icloud/contacts/

  • [PATCH] Fix find()/count() lookups on dbstl set/map

    Applies to 5.2.36
    Fix find()/count() lookups on dbstl set/map
    A bug was discovered that manifests when a custom marshaller
    is in use for objects serving as a key for either a db_map,
    or the item in a db_set. It may affect other subsystems
    (multimap/sets, etc) but this has not been explicitly confirmed.
    The symptom is that items that are inserted cannot be properly
    queried for (e.g. via .find()/.count()) within a container, yet
    the items can be iterated. It was determined that the root cause
    of this problem is related to the fact that items are inserted
    based on their custom marshaller, but are queried for using
    the default shallow/contiguous method. It is highly unlikely that
    both methods would return a comparable key, and therefore this
    explains why queries (such as via .find()) would not result
    in a match.
    The reason for the discrepancy relates to how the DBT is formed
    for a given query. In the insert path, the DBT "onstack"
    optimization was disabled, and this resulted in the DBT formation
    properly invoking the copy_function registered in the DbstlElemTraits.
    In the query path, the "onstack" optimization was enabled. This
    optimization avoids a malloc/memcpy cycle by just pointing the DBT
    to the object buffer. This is great when the buffer is already
    properly formed. However, when a copy_function is registered, this
    will hardly ever be the case. Therefore, the fix is to check
    if there is a custom marshaller registered when determining if
    the "onstack" optimization can be taken, and to skip the optimization
    when a marshaller is present. The ramification of this change is
    that DBTs formed under a custom marshaller will always be forced
    to take the malloc/memcpy hit, but this is unavoidable and logical
    anyway.
    Signed-off-by: Gregory Haskins <[email protected]>
    lang/cxx/stl/dbstl_dbt.h | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)
    diff --git a/lang/cxx/stl/dbstl_dbt.h b/lang/cxx/stl/dbstl_dbt.h
    index 43c5a19..691a9bd 100644
    --- a/lang/cxx/stl/dbstl_dbt.h
    +++ b/lang/cxx/stl/dbstl_dbt.h
    @@ -408,7 +408,7 @@ public:
    else
    sz = sizeof(dt);
    - if (onstack) {
    + if (onstack && EM::instance()->get_copy_function() == NULL) {
    freemem();
    pdbt->data = ((void*)&dt);
    // We have to set DB_DBT_USERMEM for DB_THREAD to work.

    Hi Greg,
    Thank you for addressing this. Your fix is very valuable.
    We've made some changes(including yours) to fix this kind of issue, and these changes will be in next major release.
    Regards,
    Winter Zhang
    Oracle Berkeley DB

  • Getting the average of a set of numbers, confused by file IO, please help!

    What i need to do is get the average of a set of numbers, the problem is that i am reading these numbers in from files in different directories where each file returns a number, and the average for the directory is the numbers for each file in that directory added together and divided by the number of files in that directory.
    public static HashMap readDir(File path, HashMap map) throws IOException{
            File files[] = path.listFiles();
            float totalForDirectory = 0;
             int common = 0;
             int count = 0;
                    if(files != null && files.length > 0) {
                              for(int i=0; i<files.length; i++) {
                                    if(files.isDirectory()) {
    readDir(files[i], map);
    } else {
    //trying to count the number of files in the directory
    count++;
    totalForDirectory =(total(common, totalF1(), totalF2(files[i])));
    readFile(files[i]);
    //will contain pathname, and the average
    map.put(path.getCanonicalPath(), totalForDirectory);
    return map;
    In the above code, totalForDirectory contains the number for each file, i want to add together the result of this variable for each file, "file[i]" in the directory, and divide that by the number of files in that directory.
    Id appreciate any help
    Thanks

    What you want, It seems to me, is a recursive routine (for directories) which returns both a total and a filecount. Then these can be totalled at each level (togther with the count for each file).
    Probably the best approach is to pass a small object in which the totals are accumulated.
    Define a class something like:
    public class Accumulator {
       int count;
       int total;
       public double mean() {
          return total / count;
      public void add(Accumulator add) {
         count += add.count;
         total += add.total;
       public void add(int numberFromFile) {
          count++;
         total += numberFromFile();
      }Create an instance of this at the start of your scan directory method, and pass it when you call make the recursion. At the end of the scan the method would use the first add method to add it's local totals to the hight level total.
    Obviously you create an Accumulator for the first scan directory call which becomes the grand total.

  • HT4972 "why i can't find software update menu in setting - general ". So, where is "software update" located ?

    "why i can't find software update menu in setting - general ". So, where is "software update" located ?

    You cannot update to iOS 5, it's no longer an available. You can only update to the latsest available iOS for your device. For the iPhone 4 that's iOS 6.0.1. The option you are looking for to update over-the-air requires iOS 5 or later. With iOS 4 you need to use iTunes on a Mac or PC to update the iOS. Follow the instructions on the Support Page you linked from. 

  • How do I update the TOC, after setting page numbers?

    I have set page numbers to run from Chapter 1. Actually on Page 9. but the TOC shows Chapter 1 starting at Page 7, which is not correct anyway.
    How do I cause the TOC to update? so the Chapter/Page numbers align ok.

    You need to say which version you are taking about, they behave differenetly.
    Peter

Maybe you are looking for