1 2 Previous Next 22 Replies Latest reply: Dec 20, 2009 12:40 AM by 843789 Go to original post RSS
      • 15. Re: Random Number Selection Help
        843789
        This does not work:
        flounder wrote:
        In that case I would go with sabre's second suggestion.
        value += myRandom.nextInt(2) - 0.5;
        It only adds subtracts .5 in every trial. It never adds .5... Hmmmmm, back to the drawing board
        • 16. Re: Random Number Selection Help
          843789
          s_cheplick12 wrote:
          This does not work:
          flounder wrote:
          In that case I would go with sabre's second suggestion.
          value += myRandom.nextInt(2) - 0.5;
          It only adds subtracts .5 in every trial. It never adds .5... Hmmmmm, back to the drawing board
          Sorry but id does work. Starting with an initial value of 10, a sample set of values I get are

          10.0
          10.5
          10.0
          10.5
          11.0
          10.5
          10.0
          10.5
          10.0
          10.5
          11.0

          OK, it might take a long time to reach 20 but then that is the nature of the random walk you are simulating.
          • 17. Re: Random Number Selection Help
            DarrylBurke
            s_cheplick12, this is a technical forum, not a job advertising site. I've removed the thread you started about 3 hours ago.

            db

            edit In case you hadn't seen it, there was one response on that thread.
            gimbal2 wrote:
            Learning the language is not rocket science you know; using the language to create working applications is. Since your goal right now is learning the language, it is probably easier than you are making yourself believe. All it requires is to start simple and have a goal application in mind that you want to make and a good resource to learn from, such as the java tutorial.

            http://java.sun.com/docs/books/tutorial/

            Save yourself the money man, you are only going to attract somebody that knows less than you do and will thus teach you everything you DON"T want to know or do. If you ever have a specific problem with one of your assignments, feel free to ask for help here. Just make sure you put some effort into the problem yourself first, don't expect people to write the code for you.
            Edited by: DarrylBurke
            • 18. Re: Random Number Selection Help
              843789
              Id write a method that returns
              myRandom.nextFloat()> someFloatBetweenZeroAndOne? .5; -.5;
              That method could be reused throughout the class and might add to your codes readability. You could even influence the wheigt (is that the word?) of the two possibilities by changing someFloatBetweenZeroAndOne.

              Edit: I used float here for simplicitys sake; you could, of course, use any other type that Random can return a random number of.

              Edited by: anotherAikman on Dec 15, 2009 2:37 AM
              • 19. Re: Random Number Selection Help
                843789
                <deleted>
                • 20. Re: Random Number Selection Help
                  EJP
                  Id write a method that returns
                  Why? Why wouldn't you use myRandom.nextBoolean() as already suggested?
                  • 21. Re: Random Number Selection Help
                    843789
                    Edit: NVM, misread the question. Of course, nextBoolean() is the right choice.

                    Edited by: anotherAikman on Dec 15, 2009 4:05 AM
                    • 22. Re: Random Number Selection Help
                      843789
                      Thanks...

                      I was not intending to "job post". I was more-so seeking to establish a connection with a Java expert, and maybe toss him a few dollars for his help. But I understand why the post was removed, and I have a lot of respect for these message boards.
                      1 2 Previous Next