Sip Posted November 21, 2003 Author Report Share Posted November 21, 2003 Yup Sasun .. you got it. Software ones generated using math are deterministic ... in other others, given the seed, we know what the sequence will be. That's because there is no "randomness" in the underlying mathematics and the computation. With hardware based random number generators, things are not predictable! That's what random is Domino, one way that I know of that is easy to explain is by amplifying the inherent noise (thermal noise) in a transistor. You have probably seen amplifiers everywhere ... they take a lower voltage signal and amplify it to a higher voltage for example. Now imagine a single tiny transistor. There are a lot of thermal fluctuations in it's charge level. So if you connect that to a bunch of amplifiers, you will eventually amplify that "noise" to a 0/1 signal value and now you have randomness! What exactly the distribution of that will be, depends on the nature of the noise and the materials and it is beyond my knowledge. Other thing to think about is for example acoustic noise in your microphone ... sometimes known as white noise. You can amplify that to get a somewhat "unpredictable" value too ... until Azat runs in screaming and then we have determinism again. One way you can do pseudorandom number generation in hardware is using linear feed back shift registers ... if you are interested, you can read a lot about them in these two sites which can do much better job of explaining than I can here: Linear Feedback Shift RegistersLinear Feedback Shift Registers 2 Keep in mind that a "register" is just a storage element. A shift register is when those storage elements can shift their values from one to the other. Like A1's bit value goes to A2, A2's bit value goes to A3 and so forth. A feedback is when the outputs are fed back (connected back) into the registers. If you have seen "filters" that's a similar thing in concept but not exactly. Quote Link to comment Share on other sites More sharing options...
Sip Posted November 21, 2003 Author Report Share Posted November 21, 2003 One more note about using clock to seed the random number generator to get different sequences every time your program is run ... Keep in mind what "clock" you use. Some clock functions like in Ansi C, can tick every second or every 1/18 of a second or something like that. So if you are running your program in a loop many times to do simulations, the "clock value" and therefore the seed may be the same if the program finishes too quickly! This would make repeated runs of your program redundant and skew your results. The easy solution to this is to seed the random number generator ONCE in the beginning. Then each run of the program will seed the next run of the program with the next random number (value has to be passed from program run to program run) ... or just any other method that would require the seed to be called ONCE. Note that each time a program is restarted, the seed is usually reset to some value so you have to deal with that. Quote Link to comment Share on other sites More sharing options...
DominO123 Posted November 21, 2003 Report Share Posted November 21, 2003 (edited) One way you can do pseudorandom number generation in hardware is using linear feed back shift registers ... if you are interested, you can read a lot about them in these two sites which can do much better job of explaining than I can here: Linear Feedback Shift RegistersLinear Feedback Shift Registers 2 Keep in mind that a "register" is just a storage element. A shift register is when those storage elements can shift their values from one to the other. Like A1's bit value goes to A2, A2's bit value goes to A3 and so forth. A feedback is when the outputs are fed back (connected back) into the registers. If you have seen "filters" that's a similar thing in concept but not exactly.I didn't knew of that stuff... if I understand correctly, more you add modules(the site you refered), more will approch true randomness, because you add possibilities on the serie? Is that the type of technology they use in Casinos? I am asking you this, because some years ago, here at Montreal Casino, a man after weeks studying a machine there(maybe Vava will remember), predicted the numbers and won... they claimed later that there is many series of random generators in the machine, and that one of them was missing... reducing the randomness of the machine... so when I have read this site you refered here, I remembered that module claim and replacement in the Casino. Edited November 21, 2003 by Fadix Quote Link to comment Share on other sites More sharing options...
Sip Posted November 21, 2003 Author Report Share Posted November 21, 2003 Yes with these kinds of feed back registers there is a deterministic sequence that one could maybe figure out if they knew how exactly the hardware worked. The length of the chain and the function used to feed back things definitely plays a big role as you suspect. But now, I am sure the new machines are using very randomized circuitry so it is probably very hard to guess the random number. Is there a way to "break" or "beat" the machine, maybe. But it won't be because of the weakness in the random number generator. By the way, here is another very effective method that you can use to generate randomness ... use people's response time! So you can take the time in nanoseconds that it takes a human to press a button! that is sure to have a huge degree of uncertainty to it because I don't know anyone that has faster reaction times than tens of milisecons So one really easy way to do it is to have your processor quickly go through a bunch of numbers in a pseudorandom sequence like the one above ... then a number is selected at the moment when the user presses a key! Now that's RANDOM Quote Link to comment Share on other sites More sharing options...
Harut Posted November 25, 2003 Report Share Posted November 25, 2003 how abouti = ((Rnd * 1001) Mod 1001) / 1000 am i taking the long way? here is a shorter version of that i = Int(Rnd * 1001) / 1000 interestingly enough, today, the prof asked if we could do find a way to do that (a random real number from 0 to 1 inclusive), insisting that there is a way to it. but 3 hrs later start daubting himself. Quote Link to comment Share on other sites More sharing options...
Harut Posted November 25, 2003 Report Share Posted November 25, 2003 this piece of ... code is really getting in my nerves. what's wrong with it? <%@ Language=VBScript %> <% Option Explicit %> <!--#include virtual="/adovbs.inc"--> <% If Request.Form("name") = "" OR Request.Form("message") = "" Then Response.Redirect "guest.asp?incomplete=1" End If Dim objConn, objRS Set objConn = Server.CreateObject("ADODB.Connection") objConn.ConnectionString = "DSN=Dprots.dsn" objConn.Open Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open "tblEntry", objConn, , adLockOptimistic, adCmdTable objRS.AddNew objRS("Name") = Request.Form("name") objRS("Date") = Date() objRS("Location") = Request.Form("location") objRS("Email") = Request.Form("email") objRS("URL") = Request.Form("url") objRS("Message") = Request.Form("message") objRS.Update objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing Response.Redirect "guest.asp" %> i'm getting this errorSyntax error in INSERT INTO statement. /webs/dprots/addentry.asp, line 23 why why why why Quote Link to comment Share on other sites More sharing options...
Azat Posted November 25, 2003 Report Share Posted November 25, 2003 Harut, it is really hard to debug the way that you have your insert. Using the ADO object to do the insert instead of standard SQL. My guess is either the table does not exist, or the field types do not match or one of the field names is misspelled or you have a filed that cannot be null and you are leaving it null. Sorry i know I was not much help. Quote Link to comment Share on other sites More sharing options...
Harut Posted November 25, 2003 Report Share Posted November 25, 2003 Date? bad choice for a field name. Quote Link to comment Share on other sites More sharing options...
Sip Posted November 25, 2003 Author Report Share Posted November 25, 2003 interestingly enough, today, the prof asked if we could do find a way to do that (a random real number from 0 to 1 inclusive), insisting that there is a way to it. but 3 hrs later start daubting himself.Of course there is a way to do it. In C it's trivial ... r = (float) rand() / RAND_MAX In VB, worst case you can just write the ANSI rand() function in basic. Hre is the source to an ANSI C equivalent uniform random number generator between 0.0 and 1.0 ... if you want to make your own, you can just start with that. But again, with "real values" between 0.0 and 1.0, the inclusive/exclusive end points do not matter at all. Quote Link to comment Share on other sites More sharing options...
Sip Posted December 3, 2003 Author Report Share Posted December 3, 2003 43 | ~43, that is the question. Quote Link to comment Share on other sites More sharing options...
Harut Posted December 4, 2003 Report Share Posted December 4, 2003 255, that is the answer Quote Link to comment Share on other sites More sharing options...
Sip Posted December 4, 2003 Author Report Share Posted December 4, 2003 But who asked it? Quote Link to comment Share on other sites More sharing options...
Harut Posted December 4, 2003 Report Share Posted December 4, 2003 someone who didn't really get along with geeks, but wrote all sorts of crazy palys for living. Quote Link to comment Share on other sites More sharing options...
Harut Posted December 4, 2003 Report Share Posted December 4, 2003 But who asked it? on the second thought, you are probably looking for that insane who plays with skulls. Quote Link to comment Share on other sites More sharing options...
Harut Posted December 4, 2003 Report Share Posted December 4, 2003 But who asked it? sorry Quote Link to comment Share on other sites More sharing options...
Harut Posted December 10, 2003 Report Share Posted December 10, 2003 here is a php problem that i'm having... i have a variable that holds a single character ($eachchar).how can i find the ASCII value of it?(int)$eachchar worked for a while, but now it returns 0. Quote Link to comment Share on other sites More sharing options...
Azat Posted December 10, 2003 Report Share Posted December 10, 2003 http://aspn.activestate.com/ASPN/docs/PHP/function.ord.html http://aspn.activestate.com/ASPN/docs/PHP/function.chr.html Quote Link to comment Share on other sites More sharing options...
Harut Posted December 10, 2003 Report Share Posted December 10, 2003 Azat, thanks once more Quote Link to comment Share on other sites More sharing options...
Harut Posted May 16, 2004 Report Share Posted May 16, 2004 I'm looking for ten "perfect squares" that are exactly 10-digits long. But not just any old 10-digit perfect squares; I'm looking for specific ones; these ones: 0) which 10-digit perfect square has the most zeros? 1) which 10-digit perfect square has the most ones? 2) which 10-digit perfect square has the most twos? 3) which 10-digit perfect square has the most threes? . . . 9) which 10-digit perfect square has the most nines? It should be noted that the 10 digit perfect square will be in a range between 1000000000 and 9999999999. I'll give you one. The answer to #5) is 4,555,575,025, which is 67495^2. There are more 5's in this 10-digit perfect square than in any other 10-digit perfect square. Print a table showing the sequanece number (0-9), the number (ie 67495) and its square (ie 4,555,575,025), like this: 0) _________ : _________________ 1) _________ : _________________ : 5) _________ : _________________ : 9) _________ : _________________ ============ a sample question from programming contest i participated today. Quote Link to comment Share on other sites More sharing options...
hytga Posted May 16, 2004 Report Share Posted May 16, 2004 Harut are you asking this as a queston or just for us to test ourselves? if it's a question: go from ascending to descending 1000000000 to 999999999... or vice versa and take the squares of each number. if the resulting number is not an integer then it's not a perfect square (obveously). if it's an integer, register the integers in an array or something then loop through the array and sort the numbers based ont the nubmer of 0s,1s etc some of the pros might have better and more efficient answers, so plz don't lough at me Quote Link to comment Share on other sites More sharing options...
Harut Posted May 17, 2004 Report Share Posted May 17, 2004 i just posted it for people to kill time on. go from ascending to descending 1000000000 to 999999999... or vice versa and take the squares of each number. if the resulting number is not an integer then it's not a perfect square (obveously). this was the hint we got with the answers after the competition. but, i did it differently, more efficiently. i itterated from square root of 1000000000 to the square root of 9999999999. Quote Link to comment Share on other sites More sharing options...
Azat Posted June 2, 2004 Report Share Posted June 2, 2004 I am not sure if Sipchik or anyone else has asked this question. Most likely they have. But I will give it another try today. You have 2 integers A and B How do you swap their values without using any temporary variables. Quote Link to comment Share on other sites More sharing options...
Sebastia Posted June 4, 2004 Report Share Posted June 4, 2004 ah maan, you guys need a girl badddly!!!!!!!!!!!!! Quote Link to comment Share on other sites More sharing options...
Sip Posted June 4, 2004 Author Report Share Posted June 4, 2004 ah maan, you guys need a girl badddly!!!!!!!!!!!!! What makes you think a girl can solve this? By the way, Azatik, I know the answer Quote Link to comment Share on other sites More sharing options...
angel4hope Posted June 4, 2004 Report Share Posted June 4, 2004 sebastia... Sip's answer to that will be that he met "one"-- at office depot -- but it didnt have a good/reliable hard drive--- if u dotn get it...just forget it- im not making sense anymore.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.