Page 1 of 1 1
Topic Options
#128546 - 2004-10-28 03:08 AM Kixtart Mini-putt challenge for tonight
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ok you late-night putters, get your nine iron out. Tonights Kixtart ultra-mini-putt golf challenge is as follows ...

Code:

For $i = 0 to 100

? "Random number between -1000 and 1000 = " + <the challenge>

Next



Fill in <the challenge> marker there, with some real code, that will display a random number between -1000 and 1000. No IF statements or other condional statements allowed ... just a nice simple one-liner expression type thingy.


Top
#128547 - 2004-10-28 04:29 AM Re: Kixtart Mini-putt challenge for tonight
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
I don't think you can make a random number generator of even so-so quality with a constraint like that.


PS: Hi Shawn

Does this do it?
Code:

For $i = 0 to 100 ? "Random number between -1000 and 1000 = " + <Rnd(2000)-1000>Next



Edited by Jack Lothian (2004-10-28 04:38 AM)
_________________________
Jack

Top
#128548 - 2004-10-28 04:39 AM Re: Kixtart Mini-putt challenge for tonight
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Code:

For $i = 0 to 100
? "Random number between -1000 and 1000 = " + (RND(2000)-1000)
Next

_________________________
There are two types of vessels, submarines and targets.

Top
#128549 - 2004-10-28 04:52 AM Re: Kixtart Mini-putt challenge for tonight
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Code:

For $i = 0 to 100
? "Random number between -1000 and 1000 = " rnd(2000)-1000
Next


Top
#128550 - 2004-10-28 05:14 AM Re: Kixtart Mini-putt challenge for tonight
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ja, all you guys got it ... was it too easy ? Was hoping you would have to think about it for at least a little bit.
Top
#128551 - 2004-10-28 05:22 AM Re: Kixtart Mini-putt challenge for tonight
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Wouldnt this also generate a random number between -1000 and 1000

Code:
For $i = 0 to 100 
? "Random number between -1000 and 1000 = " Rnd(9)
Next



didnt see anything about where at in between -1000 and 1000 it had to be..

Top
#128552 - 2004-10-28 05:28 AM Re: Kixtart Mini-putt challenge for tonight
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You basta! ;0)
Top
#128553 - 2004-10-28 10:28 AM Re: Kixtart Mini-putt challenge for tonight
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here's a starter:
Code:
BREAK ON


For $i = 0 to 100
"Random number between -1000 and 1000 = "+(((@TICKS+(@MSECS*2)) MOD 1001)*(1-2*(@TICKS MOD 2))+Execute("sleep (3.0+@TICKS MOD 11)/1000")) ?
Next



Because it is such a small set, this works surprisingly well.

The "Execute" is not strictly necessary, but it makes the code a single expression in keeping with the spirit of the challenge.

It's a bit of a cheat, but without a way of maintaining a seed I can't think how else it can be done.

Feel free to Golf it.

Top
#128554 - 2004-10-28 02:01 PM Re: Kixtart Mini-putt challenge for tonight
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Richard wins with the shortest solution that doesn't use RND(), which is kinda cool.
Top
#128555 - 2004-10-28 03:25 PM Re: Kixtart Mini-putt challenge for tonight
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
like said shawn...
the rules are way too loose and I vote for the citrix-basta to be winner.
_________________________
!

download KiXnet

Top
#128556 - 2004-10-29 03:14 AM Re: Kixtart Mini-putt challenge for tonight
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Cute Richard

Does it really work as well as Rnd? I suspect they might be on par but no matter I do like your solution - it is original
_________________________
Jack

Top
#128557 - 2004-10-29 10:39 AM Re: Kixtart Mini-putt challenge for tonight
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Cute Richard

Does it really work as well as Rnd? I suspect they might be on par but no matter I do like your solution - it is original




Dunno. Given that RND is not actually random this is probably just as good for this small set.

If the set was larger it wouldn't be very useful.

If you are interested in comparing the both, run for each for a couple of hundred thousand iterations and plot a histogram of the number of times that each value is returned. If the RNG is truly random then it should be a fairly flat line.

I suspect that in a tight loop like this there is a posibility of getting into a repeating sequence. In the real world where other stuff will be going on which will take a variable amount of time to complete it probably isn't an issue.

The obvious big differences are
  1. My code is much, much slower because of the need to intoduce the small sleeps to peturb the algorithm.
  2. As my code does not have a seed you cannot guarantee to repeat the sequence.
  3. There is chance that the significant bits of @TICKS and @MSECS will repeat causing a repeating sequence where the loop is very tight.

Top
#128558 - 2004-10-29 08:10 PM Re: Kixtart Mini-putt challenge for tonight
Cybex Offline
Getting the hang of it
*****

Registered: 2004-07-21
Posts: 81
Loc: Brandon, FL.
But nothing generated here is truly random. It is merely pseudo randomly generated numbers. Do we want to go here or not?
_________________________
Common sense isn't so common.

Top
#128559 - 2004-10-31 02:56 PM Re: Kixtart Mini-putt challenge for tonight
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Cybex,

There is strong & vocal movement in physics which claims nothing is random (or probalistic) & everything is deterministic. What we interpret as 'random' is in reality higher-dimensional-non-linear fractal processes that look random from our limited 3-D view point. If this is true what exactly is the distinction between 'pseudo-random' and 'random'? Our attempts at creating random number generators can be seen as attempts to mimick what nature does.


Richard,

You are being too technical. I not sure kixtart could be used to create a high quality generator that was also efficient (especially if it has to follow kixgolf rules). I think your solution is as good as it gets within the given constraints. Yes it might exhibit structure in time or fail to produce a perfectly flat distribution & it is not easily repeatable but so what. My bet is the Rnd function would fail some of the standard tests as well.


Edited by Jack Lothian (2004-10-31 03:08 PM)
_________________________
Jack

Top
#128560 - 2004-10-31 03:50 PM Re: Kixtart Mini-putt challenge for tonight
Cybex Offline
Getting the hang of it
*****

Registered: 2004-07-21
Posts: 81
Loc: Brandon, FL.
Woops, double post....

Edited by Cybex (2004-10-31 03:53 PM)
_________________________
Common sense isn't so common.

Top
#128561 - 2004-10-31 03:52 PM Re: Kixtart Mini-putt challenge for tonight
Cybex Offline
Getting the hang of it
*****

Registered: 2004-07-21
Posts: 81
Loc: Brandon, FL.
I believe I understand where you are coming from but that would insinuate that given all the environmental variables that a naturally occurring (non-mechanically generated) action or event is re-creatable. That no action is truly random and you would have the same result each and every time if it were possible to re-create. Excluding mechanical and electronic equipment I have not read or seen anything to lead me to believe that this is in fact the case.

Regarding the randomness of Richards’s code it is not truly random in the sense the outcome is re-creatable. It is not easily re-creatable but it is not impossible. Given all the environmental variables preset I.E. the uptime of the system, the current millisecond in time, and so on, and the output would be the same each and every time. Nothing of true randomness is entered into the solution. I had a discussion over lunch the other day with a friend about the possibility of using the frequency of sound captured through a microphone as the basis of a random variable in a complex pseudo random number generator. As long as you’re not trying to generate it in a vacuum it should work, and if you were you would probably be dead and would not care. He had suggested that the current location of the read heads on the hard drive may be a possible variable in the formula. O’well, I guess I’ll work on that one after I solve the Hodge Conjecture.
_________________________
Common sense isn't so common.

Top
#128562 - 2004-10-31 04:11 PM Re: Kixtart Mini-putt challenge for tonight
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
There are vaious ways to generate close-to-random numbers. One possibility is to utilize the randomness of the decay of radioactive materials, another one is to record athmospheric electromagnetic radiation and use this "noise" to generate random numbers. For more details, see http://www.random.org/
_________________________
There are two types of vessels, submarines and targets.

Top
#128563 - 2004-10-31 04:42 PM Re: Kixtart Mini-putt challenge for tonight
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Cybex,

Just because something is generated by deterministic process doesn't mean we can recreate it even if we perfectly understand the underlying processes. The current output of the hypothetical fractal processes may depend on the initial conditions in the past – possibly at the moment of creation of the universe & we can never know these initial conditions so we can never simulate the processes even if we know the equations. A rather nihilistic view point in my opinion but Mandelbrot in particular has championed this viewpoint.

Sealeopard,

These natural phenomena that you refer to, may not be random. From the paradigm that I am coming from, Einstein was right when he said that he did not believe God played with dice & there was something missing in the theory of quantum mechanics & once we found the missing element, randomness would vanish. The random & probabilistic quantum effects that we observe in our real world may actually be generated because we live in a universe with 15 dimensions with all but 4 of the dimensions collapsed. It is the projection of these higher dimensions on our 4 dimensions, which gives the illusion of randomness. The implication here is that these so-called random process may be found to have ‘structure’ by a yet to be developed statistical test. After all, this is the history of the development of random number generators. Each time we develop a new generator that overcomes a previous weakness, someone comes along and points that the new generator has an observable non-random structure. These tests for structure are becoming more & more esoteric each year. It is like peeling an onion with an infinite number of layers.
_________________________
Jack

Top
#128564 - 2004-11-01 10:22 AM Re: Kixtart Mini-putt challenge for tonight
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Regarding the randomness of Richards’s code it is not truly random in the sense the outcome is re-creatable. It is not easily re-creatable but it is not impossible. Given all the environmental variables preset I.E. the uptime of the system, the current millisecond in time, and so on, and the output would be the same each and every time.




You're missing a bit of the story. This is true, but only if the action is not subsequently subject to external influnces.

In the case of your PC it will be peturbed by small things like minor fluctuations in power supply or heat, and large things like your anti-virus software, screen saver or fast-find kicking in.

In fact, my code is *more* random than the built-in, by accident of design rather than any intention

The built-in uses a well tried and trusted method of starting with a seed number and on each iteration pushing it through an algorithm which appears to generate a random number.

The number is not of course random, it is entirely predictable. I could give you a seed number and then describe the next 10,000 numbers that will be returned every single time, without error.

You can't do that with my algorithm. If you managed to get @TICKS and @MSECS the same then the numbers at the start of the process would be identical. However, no two computers will function exactly the same, especially over an extended period. This means that without some sort of governer the results will diverge.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1172 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.08 seconds in which 0.034 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org