Help for random number generator???

hi there can anyone how to make simple random number
generator for slot machine , formula for chances in probability ,
or simple random number generator for slot machine , thanks
:)

actualy the accurate RNG for slot machine ?? any idea?

Similar Messages

  • Help: JSP Random Number Generator

    hello every one,
    Im trying to generate a random number using currentTimeMillis(), in Jsp, can you help me out and advice me how can this be done please.

    First you say you want a random number, then you say you want a unique one. Which is it?
    Random numbers do not normally guaruntee uniqueness.
    is there away i could use the currentTimeMillis(), What would you use it for? System.currentTimeMillis() is commonly used as a seed for a random number generator. The java.util.Random class uses it like that - take a look at that API link.
    Or if its a homework question state the exact requirement - I'm guessing here.

  • Does Labview have a Random Number Generator for U16 with a periodicity greater than 64 Million instances of U16words and one with SEED as the connector?

    We are doing some testing that requires 64MegaWords be written to our DSP memory  with random values to do a validity check and without repeating sequences with using the previous value as the seed for the next and us passing it the initial seed.  The dice one doesn't meet that criteria, and I was not sure how the continuous random number generator parameters work and if any of them would meet this criteria. Anyone have any information that might help?
    Thanks,
    Sue

    Hi suem,
    There is no reason why you couldn't simply write a pseudo-random number generator by yourself. Simply select a random number algorithm you want to use and implement it in LabVIEW. You do not need to interface code written in another language in order to implement a pseudorandom number generator. If you have a DAQ card or something, you can also use inputr noise or some other hardware soruce to generate real random numbers. For that also LabVIEW is an excellent tool.
    Tomi
    Tomi Maila

  • Random NUMBER generator help..

    Hi all,
    i'm having issues with my random number generator i'm trying to fill my array with random numbers but i keep getting it filled with zeros.... can any one tell me what i'm doing wrong i can;t figure it out..
    for (int i =0; i < 100; i++){
                        int x=(int) (Math.random());
                        data[i] = x;
    }

    From the API "Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0."
    So casting the value to int is always going to result in a zero value.
    You need to multiply by a value that is one larger than the value you want to be your maximum. For example:
    int x = (int)(Math.random() * 100);
    should create a random number from 0 to 99

  • Ideas on generating seeds for random number generators?

    Does anyone here have any ideas or know of any good links to articles that discuss how to generate good seeds for random number generators?
    I am aware that I could always probably call SecureRandom.generateSeed as one technique.
    The major problem that I have with the above is that I have no idea how any given implementation of SecureRandom works, and whether or not it is any good. (For instance, Sun seems to hide their implementation outside of the normal JDK source tree; must be in one of their semi-proprietary sun packages...)
    I thought about the problem a little, and I -think- that the implementation below ought to be OK. The javadocs describe the requirements that I am looking for as well as the implementation. The only issue that still bugs me is that maybe the hash function that I use is not 1-1, and so may not guarantee uniqueness, so I would especially like feedback on that.
    Here's the code fragments:
         * A seed value generating function for Random should satisfy these goals:
         * <ol>
         *  <li>be unique per each call of this method</li>
         *  <li>be different each time the JVM is run</li>
         *  <li>be uniformly spread around the range of all possible long values</li>
         * </ol>
         * This method <i>attempts</i> to satisfy all of these goals:
         * <ol>
         *  <li>
         *          an internal serial id field is incremented upon each call, so each call is guaranteed a different value;
         *          this field determines the high order bits of the result
         *  </li>
         *  <li>
         *          each call uses the result of {@link System#nanoTime System.nanoTime}
         *          to determine the low order bits of the result,
         *          which should be different each time the JVM is run (assuming that the system time is different)
         *  </li>
         *  <li>a hash algorithm is applied to the above numbers before putting them into the high and low order parts of the result</li>
         * </ol>
         * <b>Warning:</b> the uniqueness goals cannot be guaranteed because the hash algorithm, while it is of high quality,
         * is not guaranteed to be a 1-1 function (i.e. 2 different input ints might get mapped to the same output int).
         public static long makeSeed() {
              long bitsHigh = ((long) HashUtil.enhance( ++serialNumber )) << 32;
              long bitsLow = HashUtil.hash( System.nanoTime() );
              return bitsHigh | bitsLow;
         }and, in a class called HashUtil:     
         * Does various bit level manipulations of h which should thoroughly scramble its bits,
         * which enhances its hash effectiveness, before returning it.
         * This method is needed if h is initially a poor quality hash.
         * A prime example: {@link Integer#hashCode Integer.hashCode} simply returns the int value,
         * which is an extremely bad hash.     
         public static final int enhance(int h) {
    // +++ the code below was taken from java.util.HashMap.hash
    // is this a published known algorithm?  is there a better one?  research...
              h += ~(h << 9);
              h ^=  (h >>> 14);
              h +=  (h << 4);
              h ^=  (h >>> 10);
              return h;
         /** Returns a high quality hash for the long arg l. */
         public static final int hash(long l) {
              return enhance(
                   (int) (l ^ (l >>> 32))     // the algorithm on this line is the same as that used in Long.hashCode
         }

    Correct me if I'm incorrect, but doesn't SecureRandom just access hardware sources entropy? Sources like /dev/random?What do you mean by hardware sources of entropy?
    What you really want is some physical source of noise, like voltage fluctuations across a diode, or Johnson noise, or certain radioactive decay processes; see, for example
         http://www.robertnz.net/true_rng.html
         http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/
         this 2nd paper is terrific; see for example this section: http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/#page-9
    But is /dev/random equivalent to the above? Of course, this totally depends on how it is implemented; the 2nd paper cited above gives some more discussion:
         http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/#page-34
    I am not sure if using inputs like keyboard, mouse, and disk events is quite as secure as, say, using Johnson noise; if my skimming of that paper is correct, he concludes that you need as many different partially random sources as possible, and even then "A hardware based random source is still preferable" (p. 13). But he appears to say that you can still do pretty good with these these sources if you take care and do things like deskew them. For instance, the common linix implementation of /dev/random at least takes those events and does some sophisticated math and hashing to try to further scramble the bits, which is what I am trying to simulate with my hashing in my makeSeed method.
    I don't think Java can actually do any better than the time without using JNI. But I always like to be enlightened; is there a way for the JVM to generate some quality entropy?Well, the JVM probably cannot beat some "true" hardware device like diode noise, but maybe it can be as good as /dev/random: if /dev/random is relying on partially random events like keyboard, mouse, and disk events, maybe there are similar events inside the JVM that it could tap into.
    Obviously, if you have a gui, you can with java tap into the same mouse and keyboard events as /dev/random does.
    Garbage collection events would probably NOT be the best candidate, since they should be somewhat deterministic. (However, note that that paper cited above gives you techniques for taking even very low entropy sources and getting good randomness out of them; you just have to be very careful and know what you are doing.)
    Maybe one source of partial randomness is the thread scheduler. Imagine that have one or more threads sleep, and when they wake up put that precise time of wakeup as an input into an entropy pool similar to the /dev/random pool. Each thread would then be put back to sleep after waking up, where its sleep time would also be a random number drawn from the pool. Here, you are hoping that the precise time of thread wakeup is equivalent in its randomness to keyboard, mouse, and disk events.
    I wish that I had time to pursue this...

  • Defining a lower boundery for a random number Generator

    Hi,
    I am using the code:
    Random rand = new Random();
    int x = rand.nextInt(50);
    to generate a random number between 0 and 49
    However I now need to only select a number between 20 and 49
    Is there any way to give the random number generator a lower boundery as well as an upper boundery ??
    Thank you
    Craig

    example:int x = rand.nextInt(30) + 20;Will generate a number between 20 and 49.

  • Random Number Generator setSeed(); method???

    I've searched and can't get a good understanding of the setSeed() method. I am suppose to use the loop control variable to seed the random number generator inside the loop. I need to use the same input everytime I use the random generator. When I compile it says int cannot be dereferenced.
    for(int i = 0; i < array.length; i++)
    int randnum = generator.nextInt(100);
    randnum.setSeed(i);
    array[i] = randnum;
    If anyone can explain the setSeed() method that would be greatly appreciated. Thanks!

    badbro wrote:
    Thanks for your help, but leave the smart comments to yourself. They are not needed. Thats what this forum is for.All of Paul's comments were dead spot on, and if you listen to him and take his advice to heart, it will only help you. If they make you upset, well then that's your problem, isn't it? My advice: grow up.

  • Random number generator. Even and odd numbers

    I have a problem.
    I have a random number generator, it goes from 0 to 20, I need to have two indicators, one will show how many numbers are pairs, and how many are not.
    I tried to use the decimated 1D array, but since those numbers are random, it doesn´t work for me. I´m new with LabView, and I don´t know if there is some other way to make it work, I need some help, especially with some examples.
    Thank you so much.
    Solved!
    Go to Solution.

    RavensFan wrote:
    Spoiler (Highlight to read)
    Create the array.  Use quotient remainder to divide by 2.  Now you have an array where all the odd numbers are now 1, and all the even numbers are now 0.  Sum the array and you have the total number of odd numbers.  The number of evens will be the length of the array divided by the # of odds.
    Create the array.  Use quotient remainder to divide by 2.  Now you have an array where all the odd numbers are now 1, and all the even numbers are now 0.  Sum the array and you have the total number of odd numbers.  The number of evens will be the length of the array divided by the # of odds.
    Haha I lost sight of the fact that he was looking for the amount off odds and evens.  Good one.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Uniform random number generator

    anyone of u know how to generate UNIFORM RANDOM NUMBER GENERATOR that has serious faults ?

    jwenting wrote:
    uj_ is right (never thought I'd say that).
    ANYTHING "uniform" is by definition not random.Well, the correct term is "random numbers from a uniform distribution". And there certainly exist such generators (athough they're pseudo-random of course).
    I lost my temper because I've spent considerable time helping sosys only to realize he's a notorious cheater. Sosys claims to be a college student attending a CS class. With the knowledge, or rather lack thereof, he's displaying he must've cheated systematically for a long long time. I'm quite liberate at helping people with their homework but I won't help a leech become a programmer.

  • Java random number generator

    Hi does java have a random number generator. If it does can you point me to it please. Thank you.

    you can use "java.Math.random()" this function returns a value which is greater than or equal
    to 0.0 and less than 1.It returns a double value,so you can multiply by 10 and cast it to int,so that it
    can produce numbers between 0 & 9.Yes, you can do that. But, as stated before, java.util.Random has methods that are easier to use for random int values than using java.Math.random is for random int values. It all depends what the OP wants. The OP hasn't come back with additional questions, or to say that he found his answer. So, we don't know whether he has his answer (he has several options now!) or not. :)

  • Favorite random number generator.

    As I hope that not everyone is using the core java API for generating random ints, floats, etc., I was curious what RNG (random number generators) people are using. I am currently using the Mersenne Twister Fast, and have glanced at the RNG in the Colt API. What do you use? What is your favourite RNG?

    I also favor this crisp random number generator, which is adapted to Java from the book "Numerical Recipes in C++".
    http://www.nr.com/cpp-blurb.html
    public class Ran {
                  private int idum;
                 final static int IA = 16807;
         final static int IM = 2147483647;
         final static int IQ = 127773;
         final static int IR = 2836;
         final static int MASK = 123459876;
         final static double AM = 1.0 / (double)IM;
                Ran(){
                    this.idum = (int)(System.currentTimeMillis()%262144L);
                Ran(int n){
                    this.idum = n;
        final public double rand(){
         this.idum ^= MASK;
         int k = this.idum / IQ;
         this.idum = IA*(this.idum - k*IQ) - IR*k;
         if(this.idum < 0){this.idum += IM;}
         double ans = AM*this.idum;
         this.idum ^= MASK;
         return ans;
    }(This is a privately converted version, not published.)

  • Plot xy graph using random number generator

    How do i plot xy graph dynamically every 5 seconds with a random number generator?
    X axis : Time
    Y Axis : Random number generator

    I've done tis so far. im able to plot dynamically every 1 second.
    but the problem i am facing is The X axis display every 1 second.
    i want it to be fixed 24 hours time format, and the data will gradually plots the data on y axis against x axis every one second, without changing the scale of the x axis (24hour time format)

  • Random Number Generator issues

    Ok so I have an issue. I'm supposed to create a GUI app that has a frame that contains both a button and a textfield. When the button is pressed then a random number between 1 and 10 should appear in the textfield. I've got an illegal start of expression on line 49 which is the last private void...
    So what have I done wrong?
    * randomnumber.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Random;
    public class randomnumber extends JFrame
         Random randomObject = new Random();
      // declare controls used
      static JButton startButton = new JButton();
      static JTextField startTextField = new JTextField();
      public static void main(String args[])
        new randomnumber().show();
      public randomnumber()
        // frame constructor
        setTitle("Random Number Generator");
        getContentPane().setLayout(new GridBagLayout());
        // add controls
        GridBagConstraints gridConstraints = new GridBagConstraints();
        startButton.setText("Generate a Number");
        gridConstraints.gridx = 0;
        gridConstraints.gridy = 0;
        getContentPane().add(startButton, gridConstraints);
        startButton.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            startButtonActionPerformed(e);
        startTextField.setText("");
        startTextField.setColumns(15);
        gridConstraints.gridx = 2;
        gridConstraints.gridy = 0;
        getContentPane().add(startTextField, new GridBagConstraints());
      private void startButtonActionPerformed(ActionEvent e)
        myInt = randomObject.nextInt(11);
        startTextField.setText(String.valueOf(myInt));
    }Edited by: Hessmix on Oct 17, 2007 6:15 PM

    public randomnumber()
        // frame constructor
        setTitle("Random Number Generator");
        getContentPane().setLayout(new GridBagLayout());
        // add controls
        GridBagConstraints gridConstraints = new GridBagConstraints();
        startButton.setText("Generate a Number");
        gridConstraints.gridx = 0;
        gridConstraints.gridy = 0;
        getContentPane().add(startButton, gridConstraints);
        startButton.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            startButtonActionPerformed(e);
        startTextField.setText("");
        startTextField.setColumns(15);
        gridConstraints.gridx = 2;
        gridConstraints.gridy = 0;
        getContentPane().add(startTextField, new GridBagConstraints());
      }//<< Add a brace here
      private void startButtonActionPerformed(ActionEvent e)
        myInt = randomObject.nextInt(11);
        startTextField.setText(String.valueOf(myInt));
    }Did you add that brace?

  • How do I create a random number generator?

    I know I've done it before...but I can't remember quite how to get it going. I'm creating a math tutor program, which generates two random numbers and asks the user to add them, and if the answer is right they get a message that gives props and if they get it wrong they're told they got it wrong.
    I can't get too far because I've forgotten how to make the number generator, so what exactly do you put in to get it?
    import java.util.*;
    public class AssignmentFour3 {
         private static Random integer = new Random();
         double number1 = 0;
         Random string1 = new Random();
         }

    DrClap wrote:
    Generally I don't write my own random number generator. I just use the java.util.Random class.I read it as though that that is what he was going to use, but wasn't able to read the API docs to figure out what methods to use. ;-)

  • Method for a random number generator???

    I need a method to generate a random number between zero and X, X being a variable set by my program. The only method I can find is Math.random(), which generates a number between 0.0 and 1.0. (Of course, I can multiply to make it an int). Can you help me out?

    I dont know if this will help not but you could do this:
    RandomNum = (int)Math.floor(Math.random() * X);
    I think that should generate your random number between 1 and variable X
    Regards,
    Carl

Maybe you are looking for

  • Adobe InDesign CS4 Keeps Crashing #$%@@*(!

    Please help. It has been a nightmare since we installed CS4. InDesign CS3 never crashed. But since we For some reason I keep getting the error "network connection lost for the C:\file.indd or the file was modified by another process". And then the sy

  • Turning off data services

    Hi, I was just wondering why you can't use wi-fi when you select to turn data services off. The problem is, is that for this 1 month I don't have unlimited data so need to make sure I don't spend much. Also will any services try to use the data servi

  • Can't attach files or photos after microsoft update to 8.1

    I have a HP Envy Desktop all in one computer which I purchased in April 2013 with Windows 8.  Recently my Microsoft automatic update added Windows 8.1.   When that occured it knocked my printer off and I reinstalled.  I use Outlook 2013  for email. 

  • Emptying trash takes long

    I mean forever. I once wanted to remove one backup from the Time Machine drive, but when it counted about 800 000 files to be removed and started counting them down very slowly (I have a fast drive), I force killed the Locum process responsible for t

  • How to import AVCHD movies into iPhoto without wavy lines.

    Seems to be quite the common plight but few resolved answers (that I could find) ... Importing videos in to iPhoto from Sony Handycam "works", but upon viewing the quality is garbage with lines, shooting in 1080i mode at 30 fps. I know I can import i