Hilbert's Hotel

Diskussionsforum zur Unendlichkeit: Theismus, Atheismus, Primzahlen, Unsterblichkeit, das Universum...
Discussing Infinity: theism and atheism, prime numbers, immortality, cosmology, philosophy...

Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 7 1 2 3 4 5 6 7
Re: NVidia Number Test [Re: broozar] #162313
10/22/07 20:35
10/22/07 20:35
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
no, it's not the same. the multiplications are needed so that no combination happens more than once (which would bias the probabilities). i came up with that after i have seen julzmighty's solution and after some trial and error. i tried to find a version which doesn't need while() or if().

what is rand() in your example? you must only use rand5().

Re: NVidia Number Test [Re: ventilator] #162314
10/22/07 20:36
10/22/07 20:36
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
no, it's a 2/7 to 5/7 chance (see the switch()?), as i posted and explained with the drawing. could you please do a test run with my code? i'd like to have it like the millions-test you used with your code, i'm curious if it works.

Re: NVidia Number Test [Re: broozar] #162315
10/22/07 20:40
10/22/07 20:40
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
sorry, actually i wanted to ask what rand() is in your code (i have edited my question but you replied too fast). you are only allowed to use rand5().

Re: NVidia Number Test [Re: ventilator] #162316
10/22/07 20:44
10/22/07 20:44
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
rand() is a standard c/c++ function

i thought we had to use rand5(), i did not know that it was the only function we were allowed to use.

btw, how did you get the 19531? did you invent it or is there a system behind?

Re: NVidia Number Test [Re: broozar] #162317
10/22/07 20:54
10/22/07 20:54
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
with rand() it would be too easy!

19531 is the result if all rand5() return 1. so it's the minimum. i want the minimum to be 0 though so i do the subtraction.

hm... i think this solution isn't 100% mathematically correct though even if it seems to give correct results. the error just seems to get smaller the more rand5() you use in that row.

i think there is no solution without while() or if().

Re: NVidia Number Test [Re: broozar] #162318
10/22/07 21:23
10/22/07 21:23
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
EDIT: i was on the wrong page; ventilator and broozar made my explanation redundant.

julz

Last edited by JulzMighty; 10/22/07 21:28.

Formerly known as JulzMighty.
I made KarBOOM!
Re: NVidia Number Test [Re: JibbSmart] #162319
10/22/07 23:05
10/22/07 23:05
Joined: Aug 2003
Posts: 7,440
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,440
Red Dwarf
what about:

Code:
  
int rand7()
{
int answer = rand(5);
answer = (answer<7)?answer+(rand5()-3):answer-rand(5);
return (answer>0)?answer:answer+rand(5);
}



?


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: NVidia Number Test [Re: Doug] #162320
10/23/07 01:27
10/23/07 01:27
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
DELETED: Sorry, one of my "friends" thought it would be funny to post random nonsense here.

Last edited by xXxGuitar511; 10/23/07 02:15.

xXxGuitar511
- Programmer
Re: NVidia Number Test [Re: ventilator] #162321
10/23/07 05:49
10/23/07 05:49
Joined: Jul 2006
Posts: 503
Australia
A
adoado Offline OP

User
adoado  Offline OP

User
A

Joined: Jul 2006
Posts: 503
Australia
Quote:

doug, this way the probabilites aren't equal. see julzmighty's explanation. and you made a small mistake. after -7 the range is 0..28.

Code:
(rand5()+rand5()+rand5()+rand5()+rand5() - 2) / 3

gives this distribution after 1 million runs:
{1: 6864, 2: 72170, 3: 243728, 4: 355145, 5: 243124, 6: 72255, 7: 6714}



did anyone have a thought about the one i posted earlier?
Code:
(rand5() + 5*rand5() + 25*rand5() + 125*rand5() + 625*rand5() + 3125*rand5() + 15625*rand5() - 19531) % 7) + 1

is there some hidden flaw? the result seems to be correct:
{1: 143263, 2: 142785, 3: 142579, 4: 142533, 5: 143609, 6: 142520, 7: 142711}




It looks like your method returns fairly even probabilities for each number to occur? Whats wrong with this one?


Visit our development blog: http://yellloh.com
Re: NVidia Number Test [Re: adoado] #162322
10/23/07 07:06
10/23/07 07:06
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
(rand5()*0.7)+(rand5()*0.7) ?

Page 4 of 7 1 2 3 4 5 6 7

Moderated by  jcl, Lukas, old_bill, Spirit 

Kompaktes W�rterbuch des UnendlichenCompact Dictionary of the Infinite


Powered by UBB.threads™ PHP Forum Software 7.7.1