Random number game

I am writing a random numbre game which produces 6 random numbers which all must be different and within a certain range. Currently all I can get output is 6 numbers where I have duplicates e.g.
6
6
6
36
45
32
How do I make the 6 numbers different ?
Here's a small sample of the code to give you the basic idea:
import java.util.*;
public class Random
private String rNumber;
     public Random()
     String[] numlist = new String[2];
numlist[0] = "1";
numlist[1] = "2";
Random rand = new Random();
     int x = (int) (0 + (Math.abs(rand.nextInt()) % 1 )) ;
     rNumber = number[x];
     public String getrNumber()
     return rNumber;
public static void main(String args[])
     for (int i=0; i<6; i++){
     String rn;
     Random num = new Random();
rn = num.getrNumber();
System.out.println(rn);
}

Use a simple if statement that calls a method that will return a boolean value based on the random number generated(and now in english).
(1)Generate your number.
(2)Use the number as a parameter to a method.(This method checks to see if the number is already in the data structure(array,stack, whatever).
/** Checks if the given number is already contained in the given array **/
public boolean isDuplicate(int num,int[] array) {
// I have passed an array just to make it clearer.
for(int i=0;i<array.length;i++) {
if(array[i] == num) return true;
return false; // if the number is not a duplicate we know it is okay to put in our array.
// remember to keep some kind of reference to the array position.
(3) Now we just put this in the next number position in our array.
Hope this helps, by the way you wouldn't be trying to generate some numbers for a Lottery would you?(I remember when I tried that and guess what-yeah still broke)
Also call it something like RNGenerator not Random as this is already a Java class and it becomes a nightmare.

Similar Messages

  • Generating Random Number in NumberGuessing Game

    hi.. thankds for taking time to read this. please tell me how genNum works?
    public static void genNum followed by what coding? i have no idea. if possible please provide me with the necessary coding. thanks.

    I have never headr of genNum. If you want random numbers you want the following.....
    public class randomIntGenerator{
      private static long myRandom;
      private static long myMaximum;
      public static int getRandom(int maxValue){
        // Math.random() generates a random number between
        // 0 and 1.
        myRandom = Math.random();
        // To do the math you need your maximum as a long.
        myMaximum = new Long(maxValue).longValue();
        // multiply them together, then get the int value
        // and return it.
        return (new long(myRandom * myMaximum).intValue());
    }

  • Number game

    please help with this, if you can...I need to write a JAVA program to implement the secret number game. the program should create and store a random number between 1 and 10, inclusive. It should then prompt the user to guess the number. accepting user input, it should determine whether or not the guess was correct. If correct, it should print a contratulatory message and terminate. If the guess is incorrect, the program shoulod display a hint indicating that the guress was either too low ot too high. The program must validate user input. If the user enters a non-integer, it should be caught and output. If the user enters a guess outside of the valid range, an appropriate error message should be displayed either way, the user is then reprompted for a new guess.

    hi, i am giving you the code, with the specifications you have asked for, check for them, by running the code, and it will look nice if you implement this idea, to transform this code to an user interface using applets.
    import java.io.*;
    import java.util.Random;
    public class numberGame {
         public static void main (String args []) {
              boolean myBoolean = true;
              Random rand = new Random();
              int k = rand.nextInt(11);
              do{
                   try {
              BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
              System.out.println("Hi, Welcome to the secret game");
              System.out.println("Guess The Number");
              String str="";
              str = br.readLine();
              str.trim();
              System.out.println("you have entered this "+ str);
              int i =0;
              i = new Integer(str).intValue();
              numberGamePerform(i,k,myBoolean);
         }catch(Exception e){
              System.out.println("Error");
         } while (myBoolean!=false);
         public static void numberGamePerform(int i,int k,boolean myBoolean) {
              //System.out.println("My Guess "+k);
              if( i == k ) {
              System.out.println("Good Guess, Congratulations");
              myBoolean = false;
              System.exit(0);
              else {
                   System.out.println("Back Luck , Give it another Try");
                   myBoolean = true;
                   if(i<=2 && k>=8)
                   System.out.println("Input Guess too low");
                   else if (i >= 8 && k <= 2)
                   System.out.println("Input Guess too high");
                   else {
                        if((k>2&&k<=4)&&(i>=5&&i<8))
                        System.out.println("Guess relatively close but lies in the other half");
                        else
                        System.out.println("very close");
                   //if(i)

  • Random number issue

    I'm making a mobile game and I can't seem to generate a random number successfully
    Game.java:
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class Game extends MIDlet implements CommandListener {
    private Display theDisplay;
    private GameCanvas canvas;
    private Player p1;
    private Block[] Grid;
    static final Command exitCommand = new Command("Exit", Command.STOP, 1);
    class Player {
      public int x, y;
      public int width=60, height=15;
      public Player(int curX, int curY) {
       x = curX;
       y = curY;
    public Game() {
      setupGrid(5, 8, 5);
      p1 = new Player(90, 250);
      theDisplay = Display.getDisplay(this);
    private void setupGrid(int rows, int cols, int cellspacing) {
      Grid = new Block[200];
      int ind = 0;
      int posX = 10;
      int posY = 20;
      int colPosY;
      int colPosX;
      colPosY = posY;
      colPosX = posX;
      for(int x = 0; x < rows; x++) {
       Grid[ind] = new Block(posX, posY);
       colPosY = posY;
       for(int y = 0; y < cols; y++) {
        ind++;
        colPosX += 20+cellspacing;
        colPosY = posY;
        Grid[ind] = new Block(colPosX, colPosY);
       colPosX = posX;
       posY += 15+cellspacing;
       ind++;
    class Block {
       public int x, y;
       public int Health;
       public int r = 0, g = 0, b = 0;
       public Block(int curX, int curY) {
       x = curX;
       y = curY;
       double rand = Math.random()*5;
       if(rand > 0 && rand < 2) {
        g = 255;
        r = 0;
        b = 0;
       if(rand > 2 && rand < 4) {
        r = 255;
        g = 0;
        b = 0;
       if(rand > 3 && rand < 5) {
        b = 255;
        g = 0;
        r = 0;
    class GameCanvas extends Canvas {
      private int width;
      private int height;
      GameCanvas() {
       width = getWidth();
       height = getHeight();
      public void paint(Graphics g) {
       g.setColor(0, 0, 0);
       g.fillRect(0, 0, width, height);
       g.setColor(100, 100, 100);
       g.fillRect(p1.x, p1.y, p1.width, p1.height);
       for(int x = 0; x < Grid.length; x++) {
        if(Grid[x] != null) {
         g.setColor(Grid[x].r, Grid[x].g, Grid[x].b);
         g.fillRect(Grid[x].x, Grid[x].y, 20, 10);
      public void keyPressed(int keyCode) {
       int key = getGameAction(keyCode);
       if(key == LEFT && p1.x > 0) {
        p1.x-=4;
       else if(key == RIGHT && p1.x < canvas.width-p1.width) {
        p1.x+=4;
       repaint();
    protected void startApp() throws MIDletStateChangeException {
      canvas = new GameCanvas();
      canvas.addCommand(exitCommand);
      canvas.setCommandListener(this);
      theDisplay.setCurrent(canvas);
    public void pauseApp() { }
    public void destroyApp(boolean unconditional) { }
    public void commandAction(Command c, Displayable d) {
      if(c == exitCommand) {
       destroyApp(false);
       notifyDestroyed();
    }Game.java:58: cannot find symbol
    symbol : method random()
    location: class java.lang.Math
    double rand = Math.random()*5;
    ^
    1 error
    Line 58:
    double rand = Math.random()*5;

    b1nary wrote:
    Unfortunately, no - it won't work. Prior to posting this thread I researched different ways to generate random numbers but, apparently, the WTK only allows certain packages to be recognized.You can always write your own generator. For portability I use
    * Uniform random number generator.
    * <p>
    * Based on
    * <blockquote>
    * <pre>
    * Efficient and Portable Combined Random Number Generators
    * <a href="http://www.iro.umontreal.ca/~lecuyer">Pierre L'Ecuyer</a>
    * Communications of the ACM
    * June 1988 Volume 31 Number 6
    * </pre>
    * </blockquote>
    * @author Sabre
    public class Ecuyer
         * Constructs the generator based on two starting seeds.
         * <p>
         * Two generators using the same pair of seeds will produce
         * exactly the same sequence of pseudo random numbers.
         * @param seed1 the starting seed.
         * @param seed2 the second starting seed.
        public Ecuyer(int seed1, int seed2)
            s1 = (seed1 > 0) ? seed1 : 1;
            s2 = (seed2 > 0) ? seed2 : 1;
         * Constructs the generator based on a starting seed.
         * <p>
         * Two generators using the same seeds will produce
         * exactly the same sequence of pseudo random numbers.
         * @param seed the starting seed.
        public Ecuyer(long seed)
            this((int) ((seed >> 32) & 0x7fffffff), (int) (seed & 0x7fffffff));
         * Constructs a generator using the current time as seed.
        public Ecuyer()
            this(System.currentTimeMillis());
         * Returns the next random number
         * @return the next random number
        public double nextValue()
                // m = 2147483563, a = 40014
                int k = s1 / q1;
                s1 = a1 * (s1 - k * q1) - k * r1;
                if (s1 < 0)
                    s1 += m1;
                // m = 2147483399, a = 40692
                int k = s2 / q2;
                s2 = a2 * (s2 - k * q2) - k * r2;
                if (s2 < 0)
                    s2 += m2;
            int z = s1 - s2;
            if (z < 0)
                z += m1;
            return z * 4.656613e-10;
        static final int m1 = 2147483563;
        static final int a1 = 40014;
        static final int q1 = 53668;
        static final int r1 = 12211;
        static final int m2 = 2147483399;
        static final int a2 = 40692;
        static final int q2 = 52774;
        static final int r2 = 3791;
        private int s1;
        private int s2;
    }Make sure you test it thoroughly before committing to it.

  • Lingo code to show a random number

    I am learning Director and my partner and I are trying write
    lingo code for when a button is clicked, a random number between 1
    and 6 is shown in a text field. Can someone help me? I tried the
    code in the Director help that is written: diceroll = (random (6) +
    random (6)). We want it for only one die, so we didn't add the
    second random(6), but we haven't been able to figure out what else
    we should be putting in the code. Thank you.

    quote:
    Originally posted by:
    graphics cat
    I have rechecked the spelling and it's still not working.
    Most of the time there is no error message, it just doesn't do
    anything. Sometimes this error comes up - Script error:
    SyntaxEffor: missing; before statment on nouseUp me.
    Please, could you post your code or even upload your file
    somewhere we can download and check it out. This will help greatly
    in trying to find the syntax error you are making.
    In the meantime, here's a few links you can check out that
    will facilitate learning Director:
    http://www.furrypants.com/loope/index.htm
    -- advanced lingo
    http://www.fbe.unsw.edu.au/learning/director/
    -- excellent tutorials
    http://www.dreamlight.com/insights/07/
    -- learning Lingo
    http://www.andyw.com/director/
    -- technical guide, tips n’ tricks
    http://www.director-onine.com
    -- articles and forum
    http://www.mediamacros.com/
    -- for scripts and more
    http://www.xtrasy.com/ --
    for xtras and links
    http://www.updateStage.com/
    -- for quirk list, articles and xtras
    http://www.lingoworkshop.com/
    -- for some pretty advanced code
    http://groups.google.ca/groups?hl=en&lr=&group=macromedia.director.lingo
    http://groups.google.ca/groups?hl=en&lr=&group=macromedia.director.basics
    http://www.zeusprod.com/
    -- some dated technical info
    http://www.proscenia.net/resources/tutorials/director/d1/index.html
    http://www.shocknet.org.uk/
    -- internet, XML, ASP/SQL, database connectivity
    http://www.jmckell.com/ -- Math
    Lingo
    http://www.vtc.com/products/directormx2004.htm
    -- free QT How To Videos
    http://www.shockwave3d.com/
    -- shockwave games
    http://www.shocksites.com/
    -- information/news repository
    http://www.noisecrime.com/
    -- cool 3D examples
    http://www.chromelib.com/
    -- shockwave 3D behavior library
    http://www.shocksites.com/
    -- good list of Director sites
    http://poppy.macromedia.com/~thiggins/
    -- Thomas Higgins
    http://multimediahelp.org/home/director.html?action=downloads
    http://nonlinear.openspark.com/alpha/
    -- James Newton’s site. Examples
    http://nonlinear.openspark.com/
    http://www.j-roen.net/diropener/
    -- tools to extract media from dxr, dcr
    http://www.macromedia.com/support/director/
    -- official MM support site
    http://www.robotduck.com/learning/introduction/introduction1.htm
    -- tutorials
    http://brennan.young.net/Edu/Lingvad.html
    -- OOP & Space Invaders game
    http://www.markme.com/mxna/index.cfm?category=Director
    –MM XML News
    http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_18629
    http://martyplumbo.com/tutor/
    -- 3D tutorials
    http://www.ullala.at/ -- IL
    widgets & cool 3D stuff
    http://www.pm-studio.pl/xtraforum/
    -- MM Xtra Developer Forum
    http://freextras.freeweb.hu/
    -- free Xtras
    http://www.easyrgb.com/math.html
    -- colour model conversion code
    http://www.farbflash.de/director/
    -- excellent examples of IL and 3D stuff
    http://www.acm.org/tog/GraphicsGems/
    -- graphics gems code repository – IL
    http://www.toxictoy.com/resources.php
    -- several introductory tutorials
    http://www.catb.org/%7Eesr/faqs/smart-questions.html
    http://www.donrelyea.com/testdept1.html
    -- some very cool scripts
    http://director-online.com/havok/
    -- havok code, demos and more
    http://www.macromedia.com/software/player_census/shockwaveplayer/version_penetration.html
    -- shockwave penetration stats
    http://www.codeproject.com/csharp/endogine.asp#xx1253907xx
    – Endongine
    http://www.macromedia.com/software/eula/third_party/
    -- third party eulas

  • Random number problems

    I'm creating a horse racing game and I'm having a problem with my random number generator inside my threads.
    I'm creating four threads and then inside each of them I'm using:
    sleep(rand.nextInt(5) * 300);
    Which I thought would make each horse thread sleep for a different amount. Instead, my first horse thread sleeps for a random amount, then my next THREE threads sleep for the exact same amount!
    Is my random (class random) object not being seeded properly or something?
    What could be causing this?

    Ok, here is a snipped version of my code:
    public class HorseThread extends Thread {
    private Random rand;
    public void run() {
    rand = new Random();
    draw();
    private void draw() {
    // Grab the graphics object out of our JPanel
    Graphics g = panel.getGraphics();
    try {
    for (int x=0; x < 500; x+=25) {
    // Erase our racing lane
    g.setColor(Color.WHITE);
    g.fillRect(startX, startY, 500, 75);
    // Draw our horse
    g.drawImage(horsePicture, curX + x, curY, 75, 75, null);
    // Sleep a random amount
    int sleepamount = rand.nextInt(5) * 500;
    System.out.println("Horse [" + horseNum + "] sleeping for [" + Integer.toString(sleepamount) + "] milliseconds.");
    sleep(sleepamount);
    } // end for
    } catch (InterruptedException e) {
    e.printStackTrace();
    } // end try
    } // end draw()
    } // end HorseThread()

  • A simple question on random number generation?

    Hi,
    This is a rather simple question and shows my newbieness quite blatantly!
    I'm trying to generate a random number in a part of a test I have.
    So, I have a little method which looks like this:
    public int getRandomNumber(int number){
            Random random = new Random(number);
            return random.nextInt(number);
        }And in my code I do int random = getRandomNumber(blah)...where blah is always the same number.
    My problem is it always returns the same number. What am I missing here. I was under the impression that nextint(int n) was supposed to generate the number randomly!! Obviously I'm doing something wrong or not using the correct thing. Someone please point out my stupidity and point me in the right direction? Ta

    I think the idea is that Random will generate the same pseudo-random sequence over and over if you don't supply a seed value. (The better to debug with, my dear.) When you're ready to put an app into production, the seed value should be the current system time in milliseconds to guarantee a new sequence with each run.
    Do indeed move Random outside the loop. Think of it like a number factory - instantiate it once and let it pump out the random values for you as needed.

  • How do I assign images to grid cells based on their random number value?

    Hello everyone!
         I need a good point (or shove) in the correct direction.
    Background
         I've created (with previous help from this forum) a 12 x 9 random number grid which cycles through the numbers 1 to 9 a total of twelve times each. I've then created a button which shuffles the current grid's cells each time it is clicked. I now want to use 9 images that I have imported as individual symbols into the library (I have given them each their own class titled "skin1," "skin2," ... "skin9") as cell labels or the equivalent. I have also set the images up as individual movie clips (using the .Sprite class as the extended base class but keeping the actual image class names in line with their object name, i.e. the "skin1" image is the "skin1.as" class).
    Question
         How do I assign these images to the grid cells based on their respective values (ranging from 1 to 9) and have them populate the grid each time I click the "shuffle" button? So for example, in my grid the numbers 1 through 9 randomly appear 12 times each. Every time the number 4 appears in a cell, I want it to be assigned to the image "skin4" (which is just a graphic that looks like a button and has a fancy number "4" printed on it). Below is a chunk of the code I am using to draw the grid cells with:
    // Creates a grid cell when called by generateGrid().
    private funciton drawCell(_numeral:int):Sprite
              This is the code I am currently implementing to populate the grids with (although I
              don't want to use text labels as I want to fill each grid with an image according
              to its numerical value (1 to 9).
         var _label:TextField = new TextField();
         _label.multiline = _label.wordWrap = false;
         _label.autoSize = "center";
         _label.text = String(_numeral);
         // Add numerical label to cell array.
         cellLabels.push(_label);
         var _s:Sprite = new Sprite();
         _s.graphics.lineStyle(2, 0x019000);
         _s.graphics.drawRect(30, 0, cellW, CellH);
         _s.addChild(_label);
         return _s;
         While the following isn't working code, it will hopefully demonstrate what I want to achieve inside this function so I don't have to use the above snippet for text labels:
         //This will "hopefully" create an array of all 9 images by calling their classes.      var _imageArray:Array = [skin1, skin2, skin3, skin4, skin5 , skin6, skin7, skin8, skin9];      // This is what I want to happen for each cell using the above image array:      for (i = 0; i < cells; i++)      {           if (_numeral == 1)           {                // Insert skin1 image for each instance of #1 in the grid.           }           if (_numeral == 2)           {                // Insert skin2 image for each instance of #2 in the grid.           }           ...           if (_numeral == 9)           {                // Insert skin9 image for each instance of #9 in the grid.           }      } 
         Again, I don't want to use text labels. I have a custom skin graphic that I want to go over each number on the grid based on its numerical value (1 to 9). Any help with this is much appreciated!

    kglad,
         Thank you for your help with this one. Using the code below, I have successfully populated my grid cells with the desired corresponding graphics. I noticed one thing though regarding my use of the shuffle button with this particular implementation: even though the numerical values residing in each cell get shuffled, the original images remain in the grid rather than being replaced by new ones. The first code snippet below is the revised cell drawing function including your help; the second snippet shows you my simple shuffle button function (where the problem lies, I think).
    Snippet #1:
         // Creates a grid cell when called by generateGrid().
         private function drawCell(_numeral:int):Sprite
              var _label:TextField = new TextField();
              _label.multiline = _label.wordWrap = false;
              _label.autoSize = "center";
              // Creates a label that represents the numerical value of the cell.
              cellLabels.push(_label);
              var _s:Sprite = new Sprite();
              _s.graphics.lineStyle(2, 0x019000);
              _s.graphics.drawRect(30, 0, cellW, cellH);
              // Physically adds the labels to the grid.
              _s.addChild(_label);
              // Assigns a graphic class to a cell based on its numerical value.
              var _classRef:Class = Class(getDefinitionByName("skin" + _numeral));
              // Undefined variable for holding graphic classes.
              var _image:* = new _classRef();
              // Lines the images up with the grid cells.
              _image.x = 30;
              // Physically adds a graphic on top of a cell label.
              _s.addChild(_image);
              return _s;
         So far so good (although I question needing text labels at all if they are just going to remain invisible underneath the images, but enough about that for now). This next part is the reason that the images won't shuffle with the cell values, I think.
    Snippet #2:
         // When shuffleButton is clicked, this event shuffles
         // the number array and fills the cellLabels with the new values.
         private function onButtonShuffleClick(e:MouseEvent):void
              // Shuffles the number array.
              shuffle(numbers);
              // Verifies the array has been shuffled.
              trace("After shuffle:", numbers);
              // Loop replaces old cellLabels with new number array values.
              for (var i:int = 0; i < cells; i++)
                   cellLabels[i].text = String(numbers[i]);
         As you can see, it never replaces the original images that populate the grid. I tried using the _s.removeChild(image) function but that didn't work, nor would copying/pasting some of the code from snippet #1 directly into this function as it would cause another instance of the images to be placed over top of the existing ones rather than actually swapping them out. Any continued help here is greatly appreciated!
         PS Is there a quicker method for posting code into these forums without having to type it all out by hand again (i.e. copy/paste or drag/drop from my .fla or Notepad file directly into this thread)?

  • What algorithm does Excel 2010 use for Pseudo Random Number Generation (MT19937?)

    Does Excel 2010+ use the Mersenne Twister (MT19937) algorithm for Pseudo Random Number Generation (PRNG), implemented by the RAND() function?
    This has been a nagging question for some time now, with "hints" that it indeed does.  However, a relatively thorough search turns up no definitive documentation.  The most direct indication is perhaps given by Guy Melard [Ref 9] where
    he tests Excel 2010's RAND() function using the Crush battery of tests in TestU01 by L'Ecuyer & Simard.  Melard references a "semi-official" indication that Microsoft did indeed implement MT19937 for the RAND() function in
    Excel 2010, but this reference no longer seems to be available. http://office.microsoft.com/enus/excel-help/about-solver-HP005198368.aspx?pid=CH010004571033.
    The other references below [Ref 1-10] document the history of the statistical suitability of the PRNG and probability distributions in various versions of Excel.  This includes the Wichmann-Hill PRNG implementations supposedly (arguably) used in
    Excel 2003 & 2007 for random number generation.  But still, we have no answer as to which PRNG algorithm is used in
    Excel 2010 (and 2013 for that matter).
    Microsoft indicates that RAND() has been improved in Excel 2010; Microsoft states, "...and the RAND function now uses a new random number algorithm." (see https://support.office.com/en-ca/article/Whats-New-Changes-made-to-Excel-functions-355d08c8-8358-4ecb-b6eb-e2e443e98aac). 
    But no details are given on the actual algorithm.  This is critical for Monte Carlo methods and many other applications.
    Any help would be much appreciated. Thanks.
    [Ref 1] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 97. 
    Computational Statistics & Data Analysis. Vol. 31 No. 1, pp 27-37. July 1999.
    http://users.df.uba.ar/cobelli/LaboratoriosBasicos/excel97.pdf
    [Ref 2]L. Knüsel.  On the accuracy of the statistical distributions in Microsoft Excel 97. Computational Statistics & Data Analysis. Vol. 26 No. 3, pp 375-377. January 1998.
    http://www.sciencedirect.com/science/article/pii/S0167947397817562
    [Ref 3]B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and Excel XP. 
    Computational Statistics & Data Analysis. Vol.40 No. 4, pp 713-721. October 2002.
    https://www.researchgate.net/publication/222672996_On_the_accuracy_of_statistical_procedures_in_Microsoft_Excel_2000_and_Excel_XP/links/00b4951c314aac4702000000.pdf
    [Ref 4] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2003. 
    Computational Statistics & Data Analysis. Vol.49. No. 4, pp 1244-1252. June 2005.
    http://www.pucrs.br/famat/viali/tic_literatura/artigos/planilhas/msexcel.pdf
    [Ref 5] L. Knüsel. On the accuracy of statistical distributions in Microsoft Excel 2003. Computational Statistics & Data Analysis, Vol. 48, No. 3, pp 445-449. March 2005.
    http://www.sciencedirect.com/science/article/pii/S0167947304000337
    [Ref 6]B. McCullough, D.Heiser.  On the Accuracy of Statistical Procedures in Microsoft Excel 2007. 
    Computational Statistics & Data Analysis. Vol.52. No. 10, pp 4570-4578. June 2008.
    http://users.df.uba.ar/mricci/F1ByG2013/excel2007.pdf
    [Ref 7] A. Yalta. The Accuracy of Statistical Distributions in Microsoft<sup>®</sup> Excel 2007. Computational Statistics & Data Anlaysis. Vol. 52 No. 10, pp 4579 – 4586. June 2008.
    http://www.sciencedirect.com/science/article/pii/S0167947308001618
    [Ref 8] B. McCullough.  Microsoft Excel’s ‘Not The Wichmann-Hill’ Random Number Generators. Computational Statistics and Data Analysis. Vol.52. No. 10, pp 4587-4593. June 2008.
    http://www.sciencedirect.com/science/article/pii/S016794730800162X
    [Ref 9] G. Melard.  On the Accuracy of Statistical Procedures in Microsoft Excel 2010. Computational Statistics. Vol.29 No. 5, pp 1095-1128. October 2014.
    http://homepages.ulb.ac.be/~gmelard/rech/gmelard_csda23.pdf
    [Ref 10] L. Knüsel.  On the Accuracy of Statistical Distributions in Microsoft Excel 2010. Department of Statistics - University of Munich, Germany.
    http://www.csdassn.org/software_reports/excel2011.pdf

    I found the same KB article:
    https://support.microsoft.com/en-us/kb/828795
    This was introduced (according to the article) in Excel 2003. Perhaps the references in notes 2 and 3 might help.
    The article describes combining the results of 3 generators, each similar to a Multiply With Carry (MWC) generator, but with zero carry. MWC generators do very well on the Diehard battery of randomness tests (mentioned in your references), and have
    very long periods. But using zero carry makes no sense to me.
    Combining the three generators only helps if the periods of the 3 are relatively prime (despite what the article implies). Then the period of the result will be the product of the 3 periods. But without knowing the theory behind these generators, I have
    no idea what the periods would be. The formulas for MWC generators fail here.
    Richard Mueller - MVP Directory Services

  • How to get a random number in a range?

    as title
    how to get a random number in a range?
    like 2000~3000 thks :)

    int between 10 and 20 with the method Math.random():
    public class Rnd
         // Test
         public static void main(String[] args)
             int start=10, end = 30;
             for (int i = 0; i < 10; i++)
                int n = (int)(start + Math.random() * (end-start));
                System.out.println(n);
    }best regards.

  • Creation of random number through system fields

    Hi ,
    I like to create a random number generation program.(apart form system time) .
    I have noticed  that system response time differs (minimal variation in terms of milliseconds) every time
    when we execute a program .
    In that case could i know how to get the  system response time and interpretation time from system fields in program !
    Note : I like to know the table in which these values can be retrieved (like TRDIR for other system fields)

    use these function modules.
    QF05_RANDOM
    RANDOM_AMOUNT.

  • How to define "leading" random number in Infoset fpr parallel processing

    Hello,
    in Bankanalyzer we use an Infoset which consists of a selection across 4 ODS tables to gather data.
    No matter which PACKNO fields we check or uncheck in the infoset definition screen (TA RSISET), the parallel frameworks always selects the same PACKNO field from one ODS table.
    Unfortunately, the table that is selected by the framework is not suitable, because our
    "leading" ODS table which holds most of our selection criteria is another one.
    How to "convince" the parallel framework to select our leading table for the specification
    of the PACKNO in addition (this would be times 20 faster due to better select options).
    We even tried to assign "alternate characteristics" to the packnos we do not liek to use,
    but it seems that note 999101 just fixes this for non-system-fields.
    But for the random number a diffrent form routine is used in /BA1/LF3_OBJ_INDEX_READF01
    fill_range_random instead of fill_range.
    Has anyone managed to assign the PACKNO of his choice to the infoset selection?
    How?
    Thanks in advance
    Volker

    Well, it is a bit more complicated
    ODS one, that the parallel framework selects for being the one to deliver the PACKNO
    is about equal in size (~120GB each) to ODS two which has two significant field which cuts down the
    amount of data to be retreived.
    Currently we execute the generated SQL in the best possible manner (by faking some stats )
    The problem is, that I'd like to have a Statement that has the PACKNO in the very same table.
    PACKNO is a generated random number esp. to be used for parallel processing.
    The job starts about 100 slaves
    Each slave gets a packet to be processed from the framework, which is internaly represented
    by a BETWEEN clause on this PACKNO. This is joined against ODS2 and then the selective fields
    can be compared resultin in 90% of the already fetched rowes can be discarded.
    Basicly it goes like
    select ...
    from
      ods1 T_00,
      ods2 T_01,
      ods3 T_02,
      ods4 T_03
    where
    ... some key equivalence join-conditions ...
    AND  T_00.PACKNO BETWEEN '000000' and '000050' -- very selective on T_00
    AND  T_01.TYPE = '202'  -- selective Value 10% on second table
    I'd trying to change this to
    AND  T_01.PACKNO BETWEEN '000000' and '000050'
    AND  T_01.TYPE = '202'  -- selective Value 10%
    so I can use a combined Index on T_01 (TYPE;PACKNO)
    This would be times 10 more selective on the driving table and due to the fact,
    that T_00 would be joined for just the rows I need, about a calculated time 20-30 faster.
    It really boosts when I do this in sqlplus
    Hope this clearyfies a bit.
    Problem is, that I can not change the code either for doing the
    build of the packets or the one that executes the application.
    I need to change the Inofset, so that the framework decides to build
    proper SQL with T_01.PACKNO instead of T_00.PACKNO.
    Thanks a lot
    Volker

  • [JS CS3] Check the pattern of a random number given a specific data ?

    Hi all,
    I succeed getting a random number of this look : d.dd (8.73 for ex)
    I use Math.random()*(max-min)+min;
    I want to check that this number respect a specific given increment.
    To be clear :
    If I set min to 0 and max to 10 for example.
    The script returns a number like 8.56
    Now, I have a increment like 0.2
    I want the script to give me a number that can be d,d.2,d.4,d.6,d.8
    BUT NOT d.78 or d.1
    I guess I may use a while command but have no idea of the checking operation.
    Any idea ?
    Thanks in advance.
    Loic

    Math to the rescue. You want a random integer div 5.
    Math.floor(5*(Math.random()*(max-min)+min))/5 should do it.

  • How to generate a random number within a specified tolerance and control that tolerance.

    I am trying to simulate data without using a DAQ device by using a random number generator and I want to be able to control the "range" of the random number generated though.  On the front pannel, the user would be able to input a nominal number, and the random number generator would generate numbers within plus or minus .003 of that nominal number.  The data would then be plotted on a graph.  Anyone know how to do this?  Or if it's even possible?
    Just for information sake, the random number is supposed to look like thickness measurements, that's why I want to simulate plus and minus .003 because the data could be thinner or thicker than the nominal.  
    Thanks in advance!!
    Solved!
    Go to Solution.

    You can create a random number with a gaussian probability profile using two equal distributed (0...1) random numbers and applying the Box Muller transform.
    I wrote one many years ago, her it is. (LabVIEW 8.0). 
    Message Edited by altenbach on 04-12-2010 09:13 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    BoxMuller.vi ‏10 KB

  • Is there any way to generate random number in CPO

    Requirement : -
    > I want  to generate a random number from set of 1-9 numbers .is there any way in cpo ?
    Thanks
    Siva

    I created a process that uses 3 steps, all of which happen inside the engine rather than having to span out to a script, so it runs a lot faster.
    Technically, it's pseudo-random...
    Predefine Output Variable "Random Number" as type "Numeric"
    Step 1:  Format Date
      Format string: fffffff 
        (that's seven lower-case letters "f")
      Original date: [Process.Start Time]
    Step 2: Format Date
      Format string: ff\0\0\0\0\0
      Original date: [Process Start Time]
    Step 3: Set Variable
      Variable to update: [Process.Variables.Output.Random Number]
      New value: ([Workflow.Format Date.Formatted Date]-[Workflow.Format Date (2).Formatted Date])/100000
    This returns a basically random number between 0 and 1 (so you can mulitply it by your maximum value) based on the numeric fraction of a second of the start time of the process.

Maybe you are looking for

  • Problems with urldecoding of %

    hi, in my servlet's post method i set request_.setCharacterEncoding("UTF-8"); and then i gonna urldecode the parameters with String value = request_.getParameter(PARAM); String decValue = URLDecoder.decode(value.trim(), "UTF-8"); everything seems to

  • Deleting Project Coding Mask

    Hi, I want to delete one of coding mask but Iu2019m getting the below error message even though Iu2019ve rename all the Z Projects to start with character u201CPu201D. If I execute CN41 report I cannot see all the u201CZu201D Projects but the project

  • Applescript stopped working, error -1708

    Hi, Applescript has stopped functioning on my computer as of yesterday. No applescripts are working. The problem has appeared on four other Macs in our office. Here is a sample of what I am seeing running the script in ScriptEditor: tell application

  • Errors in reloading software & drivers

    I have an HP Photosmart D110a printer.  I currently am using the Windows 7 operating system.  I have had this printer for 2-3 years.  Initially, I set the printer up to use a wireless connection; that way everyone in the house could use the same prin

  • FM to read routing information

    Hi experts,                           My requirement is to copy routing , for that I am using BAPI_ROUTING_CREATE. I need to read routing details and populate the BAPI tables for new routing creation. I searched in SCN and i cud find a few  FMs ,but