How good is the Collections.shuffle() method?

Hello
I have an ArrayList which I want to bootstrap from. I did not find any method to randomly select an entry from the ArrayList, so I use the shuffle method first, and then get the first entry (which should be random after each shuffle). However, I do get some strange results from this. On average the numbers gotten when I sample small series is lower then the ones I get sampling longer series. There is no aspect with the data that should imply such behavoiur. Does anyone know how good my way of sampling is (using shuffle), and if the shuffle method really is a good way to randomize?
Regards
JT

I think the API docs probably give the best answer to this question. Notice the word "approximately" In the shuffle(List) method. Also note that shuffle.(List, Random) depends on how "good" Random is.
I guess you'd have to construct some form of test to see if either shuffle was good enough for your requirements.
Cheers
DB

Similar Messages

  • How to call the screen in methods could u please explain

    hi,
    how to call the screen in methods could u please explain clearly with example

    HI ,
    CALL SCREEN - Call a screen
    Basic form
    CALL SCREEN scr.
    Addition:
    ... STARTING AT x1 y1 ... ENDING AT x2 y2
    Effect
    Calls the screen scr; scr is the number of a screen of the main program. You use SET SCREEN 0. or LEAVE SCREEN. to define the return from the CALL screen.
    Note
    Please consult Data Area and Modularization Unit Organization documentation as well.
    Addition
    ... STARTING AT x1 y1  ENDING AT x2 y2
    Effect
    The coordinates x1, y1 (start column and start line in the window) and x2, y2 (end column and end line in the window) define the size and position of the CALL screen ("top left - bottom right"). Besides these coordinates, you can also see the contents of the primary window, but cannot perform any action there.
    Note
    If "ENDING AT ..." is not specified, suitable values are substituted for x2 and y2, taking into account the size of the called screen.
    Exceptions
    Non-Catchable Exceptions
    Cause: No further screen level (call screen); the maximum number of nested screen levels is restricted to 50 at present.
    Runtime Error: DYNP_TOO_MANY_CALL_SCREENS
    THX

  • How good is the audio jack?

    In the past I've connected my iPod to my stereo using a mini to RCA adapter. It gave me a weak signal (even with the volume turned all the way up). How good is the Mac Mini's audio when plugging into a stereo? Thanks.

    Optical out to a DAC supports 24-bit (and even 32-bit on the new mini, whatever that is for, I guess DSP). It shares the analogue headphone jack out, but when you put a mini Toslink in it, you get the light out.
    You can also use USB out or use a USB/coax converter (which I am messing around with). Others have told me that the USB/coax converter is better because it externally clocks the signal, but I cannot hear any difference between that and the optical out. Optical goes up to 96kHz sampling frequency. To get higher, you need the USB/coax adapter.
    The NOVA that I have, linked to above, supports 16-bit output from USB and 24-bit output from optical toslink and coax. I think the USB limitation might be imposed by the software in the DAC, however, not at the mac end.

  • How good is the 3G arial on the iPad?

    How good is the 3G arial on the iPad? For example is it better than the iPhone 4 one?

    I'm using the IGP on 2 networked pc's and to be honest have had no problems with it. Runs all my games at ease inc the network games, (some are very power hungry too). Ok not as fast as the latest all singing cards but costs you nothing. You can always stick another card in if you get problems. One thing though, gotta make sure you make use of the Dual channel memory, this really speeds things up with the IGP in use.

  • How good is the Stock Cooler

    Hi ppl.
    As u prob know I am building a PC for my friend. It will be a AMD 64 3200
    My question is if I bought the retails then how good is the cooler? Also will it come with a Thermal Pad  
    If I bought the retail could I scrap off the Pad and used Thermal Paste Supplied with my Zalman 7000Al/Cu as this isnt silver based. Would this boid the warrenty.
    Or I would buy the OEM version and get a Thermaltake Silent Boost along with Artic Silver 3.  
    Wot would u guys do because u get a warrenty with the one and not with the other. I think the Silent Boost would be a much better option for cooling.
    My friend will be doin now otherclocking but wants a stable cool running system without being very loud (so no TORNADOS lol)  
    Cheers
    SAspaz  

    Quote
    Originally posted by RLiu818
    Quote
    Originally posted by skank
    The stock cooling is very adequate if you are not overclocking, enable cool and quiet and it will be pretty silent when not under load as well.  The thermal pad it comes with is fine too.  I used the stock cooler before I got my new mobo and HSF, kept my A64 at 38 deg idle, 43 deg under load.  Perfectly fine temps.
    what does cool n quiet do exactly?
    i enabled it in my BIOS and i dont notice any difference,
    i have a SLK948U with a Panaflo L 80mm
    You need to have your fan plugged into the motherboard CPU fan header for it to reduce fan speed, I guess you don't with that fan as it draws too much current.
    Oh and even if you are going to Overclock you will find the stock cooler is actually fine for mild overclocks of a couple of hundred mhz, I tried it with my Clawhammer and got it to 2200 mhz with 41 deg idle and 48 deg under load, temps that are fine in my opinion.

  • How good is the latest iMac 21.5inch 500gb

    How good is the latest iMac 21.5inch 500gb

    That is very subjective. Better than what I'm using and it works fine for what I do.

  • How good is the iPod Touch Upgrade?

    How good is the iPod touch upgrade? is it really worth it? should i upgrade? or should i wait for the sdk to come out and then upgrade?
    And are there any safety/security features for safari? to protect your ipod touch from hacks and viruses?

    There were some Mac viruses in the past (like 10 years ago), but none for OS X.
    Sophos provides a list of Mac viruses here. Almost all are from the late 1980's and early 1990's. The most recent one being June 1998 - and all of them affecting Mac OS 7, 8 or 9 - none for Mac OS X
    Virus software on the Mac mainly detects and protects against passing on Windows viruses, which do nothing on a Mac.
    In fact, Virus protection software on the Mac is a bit of a scam, as there's none to protect against.
    A couple of 'proof-of-concept' viruses were demonstrated for OS X but never released, and as I said, there's not a single virus in the wild that affects current shipping versions of OS X.
    Not a single one.

  • Reg - how to find the purpose of methods in a class

    hi everyone,
               can u plz help me with how to find the purpose of methods in a class???????
    a description abt the methods in a class??????
                        thx in advance,
    regards,
    balaji.s

    Hi Balaji
    Pls find some stuff.
    reward pts if help.
    The following statements define the structure of a class:
    ·        A class contains components
    ·        Each component is assigned to a visibility section
    ·        Classes implement methods
    The following sections describe the structure of classes in more detail.
    Class Components
    The components of a class make up its contents. All components are declared in the declaration part of the class. The components define the attributes of the objects in a class. When you define the class, each component is assigned to one of the three visibility sections, which define the external interface of the class. All of the components of a class are visible within the class. All components are in the same namespace. This means that all components of the class must have names that are unique within the class.
    There are two kinds of components in a class - those that exist separately for each object in the class, and those that exist only once for the whole class, regardless of the number of instances. Instance-specific components are known as instance components. Components that are not instance-specific are called static components.
    In ABAP Objects, classes can define the following components. Since all components that you can declare in classes can also be declared in interfaces, the following descriptions apply equally to interfaces.
    Attributes
    Attributes are internal data fields within a class that can have any ABAP data type. The state of an object is determined by the contents of its attributes. One kind of attribute is the reference variable. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.
    Instance Attributes
    The contents of instance attributes define the instance-specific state of an object. You declare them using the DATAstatement.
    Static Attributes
    The contents of static attributes define the state of the class that is valid for all instances of the class. Static attributes exist once for each class. You declare them using the CLASS-DATA statement. They are accessible for the entire runtime of the class.
    All of the objects in a class can access its static attributes. If you change a static attribute in an object, the change is visible in all other objects in the class.
    The technical properties of instance attributes belong to the static properties of a class. It is therefore possible to refer in a LIKE addition to the visible attributes of a class – through the class component selector or through reference variables, without prior creation of an object.
    Methods
    Methods are internal procedures in a class that define the behavior of an object. They can access all of the attributes of a class. This allows them to change the data content of an object. They also have a parameter interface, with which users can supply them with values when calling them, and receive values back from them The private attributes of a class can only be changed by methods in the same class.
    The definition and parameter interface of a method is similar to that of function modules. You define a method meth in the definition part of a class and implement it in the implementation part using the following processing block:
    METHOD meth.
    ENDMETHOD.
    You can declare local data types and objects in methods in the same way as in other ABAP procedures (subroutines and function modules). You call methods using the CALL METHOD statement.
    Instance Methods
    You declare instance methods using the METHODSstatement. They can access all of the attributes of a class, and can trigger all of the events of the class.
    Static Methods
    You declare static methods using the CLASS-METHODSstatement. They can only access static attributes and trigger static events.
    Special Methods
    As well as normal methods, which you call using CALL METHOD, there are two special methods called constructor and class_constructor that are automatically called when you create an object or when you first access the components of a class.
    reward pts if help.
    deepanker

  • How good is the Airport Express inbuilt Digital to Analogue converter?

    How good is the Airport Express inbuilt Digital to Analogue converter?
    I have just purchased a 2012 dual band Airport Express which has the combined optical/3.5mm analogue jack audio output.
    This is to connect to my hifi seperate amplifier, which does not have an optical input.
    This gives me a couple of options
    a) just use a standard 3.5mm jack to phono cable (and use the built in DAC in the airpor express)
    or
    b) purchase a seperate DAC to convert the optical from the Express into phono and connect that to the amplifier
    I will be sending 250-320kbps music to the airport express wirelessly.
    Will I see much/any benefit in sound quality with option B vs option A?
    I ask because option A is free (I already have the cable) and option B will be around £20-£30 depending on which DAC I were to buy (I would also need a new TOSlink optical cable).
    These are the sort of DACs I was looking at.
    Thanks, Chipstix

    How good is the Airport Express inbuilt Digital to Analogue converter?
    Please check out this stereophile article on the earlier AirPort Express. I understand that the newest version may use basically similar audio hardware.
    I will be sending 250-320kbps music to the airport express wirelessly.
    The AirPort Express Base Station (AX) works only with iTunes v4.6+ and is limited to music files that iTunes can read; ie, 16-bit data only. (An exception is you can use a third-party product like Rogue Amoeba's AirFoil to stream other non-iTunes sources.) These data, though, can be in any file format that iTunes recognizes, from lossy MP3s at the low-quality end of the spectrum to Apple Lossless and lossless AIF or WAV files at the high end. It is also important to note that the AX functions only at a 44.1kHz sample rate. When you play 32kHz or 48kHz data, iTunes sample-rate-converts the data in real time before sending it to the AX.
    iTunes uses a QuickTime CODEC to convert audio files to Apple Lossless, and then, uses AirPlay to send them to the AX. In turn, the AX uses built-in software that converts the Apple Lossless to an Encoded Digital Audio format. From there, digital audio is sent to a optical transceiver to convert the electrical signal to an optical one before sending it to the innermost part of the audio port. As you already know for analog, the AX has a built-in DAC to convert the Encoded Digital Audio to Analog which is sent to the same audio port.
    One operational glitch is the fact that, as the AX doesn't have a local clock circuit, when the incoming data is interrupted, as it is when you change songs in iTunes, there is no longer a digital output to feed the DAC, which loses lock as a result. Using an external DAC, which may offer better audio performance, may have issues with this glitch. Some DACs are more sensitive than others.

  • How good are the WD MyBook Studio Ed. Refurbished Replacements?

    I have a Western Digital MyBook Studio Edition for Mac - External Hard Drive that is 2 years old, and has started to have problems.
    It keeps running constantly and gets very warm. I unplug the cables from it, let it cool for a few minutes, replug the cables, and do a forced backup.... but the next scheduled backup, it starts up and will keep running for hours without doing the backup.
    So I unplug it again, let it rest, replug, then do a forced backup, and everything repeats itself as previously mentioned.
    I called WD Support this morning, and she said that I could send it in, and they would send me a refurbished replacement. I have read on other forums (tools, etc.) that people send items in for a replacement, and they get back a refurbished unit that is all banged up, and doesn't work properly.
    My question is... how good is the WD refurbished replacements that they send back. Are they in good condition? Does anyone have any experience with WD on this?
    I have even thought of just getting a new external HD from another company, (G-Drive, LaCie, etc), but I have seen mixed reviews on them. I like the G-Drive Solid State (no moving parts) but that is over $500.... too rich for my blood.
    Any recommendations on either question.
    Thanks,
    Jim

    From what I've read on the internet WD offer poor customer service and their products are of low quality. Certainly I have experienced first-hand many WD hard drives failing, mostly with the dreaded click click click. I've only known two or three Seagates go this way in all the years I've been using hard drives (pretty much since the early days of 120MB).
    It may be expensive, but I highly recommend the ReadyNAS Duo as a backup solution and / or as general network storage. I have one set up with two 1TB Seagate NS drives in mirrored mode and it works very well. Seagate NS drives are enterprise-standard, designed for use in RAID hardware where they will be in close proximity to one another, Seagate AS drives are not designed for this purpose and so may fail in this situation. Other hard drive manufacturers make enterprise-grade drives too, I'm guessing that the ones WD use in their MyBook products are not these drives though which might explain why there are so many failures. The enterprise-grade drives typically cost about £20 more but I think for reliable backup purposes it's well worth the extra expense.

  • An April fool subject - fooling around the collections add method

    Here is a situation of an application business logic:
    A user can only add one feedback to a comment. I try to define how a feedback can be added into a comment by redefining the equal and hashCode methods.
    public class Feedback implements Serializable {
         public enum VALUE {
              NEGATIVE, POSITIVE
         protected Integer id;
         private Comment comment; // refer to a comment
         private User user;     // who gives this feedback
         private VALUE value;
         @Override
         public int hashCode() {
              final int prime = 31;
              int result = 1;
              result = prime * result + ((comment.id == null) ? 0 : comment.id.hashCode());
              result = prime * result + ((user == null) ? 0 : user.hashCode());
              return result;
          * (non-Javadoc)
          * @see java.lang.Object#equals(java.lang.Object)
         @Override
         public boolean equals(Object obj) {
              if (this == obj)
                   return true;
              if (obj == null)
                   return false;
              if (getClass() != obj.getClass())
                   return false;
              CommentFeedback other = (CommentFeedback) obj;
              if (comment.id == null) {
                   if (other.comment.id != null)
                        return false;
              } else if (!comment.id.equals(other.comment.id))
                   return false;
              if (user == null) {
                   if (other.user != null)
                        return false;
              } else if (!user.equals(other.user))
                   return false;
              return true;
          public class Comment {
             private Set<CommentFeedback> feedbacks;
               private transient short totalFeedbacks;
             private transient short positiveNumber;
             private transient short negativeNumber;
         public boolean addFeedback(CommentFeedback fb){
              boolean added = this.getFeedbacks().add(fb);
              if(added){
                   this.totalFeedbacks++;
                   if(fb.getValue() == CommentFeedback.VALUE.POSITIVE)
                        this.positiveNumber++;
                   else
                        this.negativeNumber++;               
              return added;
         }I don't get the expected behavior. A feedback with the same comment and user of an existing one in the feedback collection of the comment classs can be added into the collection. Anything is missing here?

    BigDaddyLoveHandles wrote:
    For starters, you can clean up equals with a helper method:
    public boolean equals(Object obj) {
    if (this == obj)
    return true;
    if (obj == null)
    return false;
    if (getClass() != obj.getClass())
    return false;
    Feedback other = (Feedback) obj;
    return
    equals(id, other.id) &&
    equals(comment, other.comment) &&
    equals(user, other.user) &&
    equals(value, other.value);
    public static boolean equals(Object a, Object b) {
    return a==null ? b==null : a.equals(b);
    What is wrong the equal method, then?
    Second, should equality depend on id?
    Third, your equality depends on comment's id, not on comment's equality.
    Fourth, you don't consider field value.Why not? The comment entity id is unique. Any other fields don't need to be considered for the reason I mentioned in the question (the first poster).
    [Recommend and review web sites|http://homepage.kgbinternet.com] - a fresh approach of building an open source, useful, and dynamic web site directory
    Edited by: vwuvancouver on Apr 17, 2009 9:01 AM

  • How to use the VBS MoveFolder methode in DIAdem without any error message?

    Hi,
    I want to move folders with the VBS MoveFolder methode, but in DIAdem I run in problems. When I use the following comman    fso.MoveFolder(project_folder & test_folder, project_folder & test_folder & "\" & test_ & " " & test_count) 
    I get error message
    "During call a sub routine no parentheses are allowed!"
    When I remove the brackets and use    fso.MoveFolder project_folder & test_folder, project_folder & test_folder & "\" & test_ & " " & test_count 
    I get the error message
    "Invalid sub routine call."
    How I have to use the command right?
    (the text of error messages is free translated from German Version of DIAdem 11.0! Take only the sense, not the exact wording!)
    Thanks for help.
    Regards
    Sven

    Hello Sven!
    Just add a 'Call' at the beginning of your first line will solve the syntatic error. I recommend always to use 'Call' and parenthesis.
    But there is a fundamental problem in your code: MoveFolder moves a folder from a source to a new destination and the old source folder will be deleted. You try to move a folder to a location below the same folder. If the MoveFolder wouldn't recognize these situtation and throws an error all of your data would be deleted!
    Just print out your paths in a Messagebox to clearify the situation.
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • How to reimplement the handleUnload javascript method ?

    Hi all,
    we are facing an issue here with a generated BPS application(using BPS_WB) which is integrated in another BSP application (cProjects). In fact, often, users are clicking on another tab in cProjects, and they are losing the data they were creating in the BPS application.
    They want to have a popup window that tell them that data will be lost, and have somehow the choice to cancel or save the data.
    I managed to make this work by redefining the handleUnload() javascript method which is generated in the page when doing the customizing in BPS_WB transaction (i went in the generated BSP application in SE80 to do this).
    But the problem is that each time they will change something in BPS_WB, my changes are lost ! So what is the recommandation to avoid this problem ?
    Thank you in advance,
    Xavier

    hi Xavier
    I'm afraid I don't know how to avoid this.
    I just want to know what javascript you have written to manage the popup window?
    Thank you!
    Best Regards,
    delma

  • How good is the new Adobe Reader IOS for fillable forms and interactive pdfs?

    At last adobe reader for ios has been updated so now fillable forms can be completed on ipad/iphone but how good is it?
    I've tested a form and reset form/print form and save as buttons do not seem to work.
    Form submit seems ok, just wondered what others thought?
    Also the new Adobe Reader IOS is now able to display interactive pdfs with buttons such as go to next page etc yet page transitions do not work? Again whats everyone elses opinion on the reader ios update?

    My preliminary experience is that Reader does better with forms than with interactivity.
    I've written a couple postings on InDesignSecrets.com about PDF readers for tablets. Here's the latest one:
    Finding the Best Tablet PDF Reader
    You should also check out PDF Expert (US $9.99) which handles interactivity better than Reader if that is important to you.

  • 24bit interface into 16bit GB - how good is the conversion?

    I have a Focusrite Saffire LE interface which I'm planning to use for recording into GarageBand. It's a 24-bit interface, but as GB only allows 16-bit recording some conversion must take place...
    Do you know how good the conversion is?
    Is it a proper conversion with dithering or are the least significant bits just truncated?
    Mac Mini + G3   Mac OS X (10.4.9)  
    Mac Mini + G3   Mac OS X (10.4.6)  

    hey there alfredo,
    what software will you be using? GB3 & earlier will only support 16/44.1, CD quality. the hardware interface will also come into play-what will you be using?
    for example-i have a MOTU 828 that does 24/96, but even w/ GB3 it dithers down & goes in as 16/44.1; but w/ MOTU DP4 i can use the 24/96 setting. Logic Pro will support 24/96 & ProTools HD w/ dedicated hardware will support 24/192. iTunes will support 16/44.1. generally the higher bit & sampling rates are for recording, no matter what it goes in as when burning to an audio CD it becomes 16/44.1 the industry standard.

Maybe you are looking for