Sip
Members-
Posts
8,324 -
Joined
-
Last visited
-
Days Won
5
Content Type
Profiles
Forums
Events
Gallery
Everything posted by Sip
-
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
-
NO what I want to know, is what part of this thread is "beta".
-
I don't know guys ... maybe Nasty is right. I think I'm having doubts that the Turks butchered the Armenians... maybe it is all a lie. I mean just look at that picture. It's so convincing
-
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.
-
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 Registers Linear 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.
-
No what I am saying is that that particular function can be used to generate a uniformly pseudorandom sequence of numberes that will not repeat until a VERY large number of iterations. Given that get_rand() can produce a random variable with uniform random value from 0 to 1, here's how you can get a gaussian (normal) distribution using two such random variables t1 and t2. double gauss () { double t1=get_rand(); double t2=get_rand(); if (t1<TOLERANCE) t1=TOLERANCE; return (sqrt(-2.0* log(t1))*cos(t2 * TWOPI)); } Tolerance is a very small number but you basically need that since log(0) is undefined. Again, when dealing with computers you always have finite precison problems but for all practical purposes such things are more than accurate (and random) enough. But keep in mind there are many ways to do these things. The math part is not my strength and I just know enough to have been able to use them over and over for different simulations and things.
-
Ok fellas ... a bit more on this if you are interested These functions that we are talking about, generate "pseudorandom" sequences. This means by repeatedly calling the funtion you get a sequence of values that is random. But wherever you start in the sequence of numbers, you will get the same set of numbers in order. The seeding (or randomizing) just decides where to start in the sequence. This is good for when you are writing a simulation or a program or a game that needs random things, but should be repeatable. In other words, next time you run the simulation with a different set of parameters, you may want the same random data to see how your simulation is behaving. Here is an example of such a pseudorandom generator ... it is for a uniform distribution ... transforming this to other distributions like to "normal" is not that hard. There are many different kinds some providing different levels of randomness ... the "size" of your number representation will determine how your function should work ... so this is probably for a 32-bit machine. #define MODULUS 2147483647 /* DON'T CHANGE THIS VALUE */ #define MULTIPLIER 48271 /* DON'T CHANGE THIS VALUE */ #define CHECK 399268537 /* DON'T CHANGE THIS VALUE */ #define STREAMS 256 /* # of streams, DON'T CHANGE THIS VALUE */ #define A256 22925 /* jump multiplier, DON'T CHANGE THIS VALUE */ #define DEFAULT 123456789 /* initial seed, use 0 < DEFAULT < MODULUS */ static long seed[STREAMS] = {DEFAULT}; /* current state of each stream */ static int stream = 0; /* stream index, 0 is the default */ static int initialized = 0; /* test for stream initialization */ double Random(void) /* ---------------------------------------------------------------- * Random returns a pseudo-random real number uniformly distributed * between 0.0 and 1.0. * ---------------------------------------------------------------- */ { const long Q = MODULUS / MULTIPLIER; const long R = MODULUS % MULTIPLIER; long t; t = MULTIPLIER * (seed[stream] % Q) - R * (seed[stream] / Q); if (t > 0) seed[stream] = t; else seed[stream] = t + MODULUS; return ((double) seed[stream] / MODULUS); } As you can see, basically the function does a bunch of long multiplication, division, and then modulous on BIG numbers and basically the "remainder" can be shown to be "random". It will repeat but after like 2^32 (I am guessing) or some huge number of iterations. These are done in "software". If you are still interested, I can tell you how in hardware one can generate random numbers ... and for example what kinds of things they are doing in Vegas machines to get "true" randomness. Interestingly enough, I had a question on this in my last midterm I gave on linear feed back registers
-
I'll post a detailed answer soon about the true randomness but for now, just take my word that what is generated is random enough (i.e. mathematically they can prove that there is no pattern to it for very very very long sequences). However, depending on where the "seed" is (i.e. where you start taking numbers from the sequenc) things will be the same. In other words, if you seed the random number generator at 10, every time you wil get the same sequence of random numbers. This is why it's pseudo random. In order to get randomness, people use tricks like Domino is saying which is seeding the generator by the current clock value which will be different every time a program is run. But more on this later.
-
Azat, he wants a real value. You don't want the "int". Although for integers that works fine, if you take "INT" out, with what you wrote you have values from lowerb (inclusive) to upperb + 1 (non inclusive).
-
why not just RND? Are you worried about the inclusive/exclusive thing? Here's a brief reminder from statistics ... if you have a uniform random variable X between range 0-1 (inclusive let's say), the Probability P(X=a) = 0 for a given real value a. So in other words, the probability that you get 1 (or 0) or any other given value a is 0. So if you just want a floating point random value between 0 and 1, just use RND. Between x and y, just use (y-x) * RND + x Of course all these are "pseudorandom" anyway. So what are you trying to do that you are so worried about the inclusive/exclusive end points? Is possibility of getting exactly 1 really that important to what you are doing? Because most often this is a non issue.
-
Doesn't rnd() in VB give a random number between 0 and 1? (I think less than 1) Why can't you do the same thing as in C?
-
suppose r() is a function that returns a random real value between 0.0 and 1.0 inclusive. In C/C++, you can for example have: r = (float) (rand() % 1001) / 1000.0 To get between x and y, you want: if (xelse R = (x-y) * r + y You can also use RAND_MAX to get r but I usually just rely on the above. So the question is, how random do you want it! Obviously this is not truely random since we have at most precison of 3 digits after the decimal. Oh and note here that if x and y are very far apart, this is not a good way to do it.
-
http://zr2.cs.ucla.edu/hf/eclipse.jpg I took these pics from inside my house (behind the window) with my damaged camera.
-
Happiness is when you figure out you need to have static gcc libraries installed when your VLIW compiler package says can't find lib -lm
-
Hey nasty, what are you trying to say by the way after all this crap? Are you trying to say the Ottomans didn't butcher all those Armenians? If so, you're wasting both your time and valuable bandwidth and disk space here. That's just dumb dude.
-
Happiness is losing $5 on roulette knowing that if you had won, you would probably have lost $150 the next round.
-
heheheh ... I guess you don't know Azat! Just read what I said carefully and you'll see that as soon as I mentioned "I'll supply the beer", Azat probably reserved his plane tickets
-
Helllllllo? Is anybody reading what I said? I said I have plenty of extra room. LOTS and lots of it.
-
I'm not into books at all. I think I've read one novel back in 96 when I was bored and had nothing to do at work (and no internet). I can comfortably say that I hate reading books although I used to read a lot when I was young (pre teen) and bored.
-
You know the funny thing is, I could say exactly the same things!!! Especially with Thanksgiving coming up Proud to be an American and I love turkey. http://www.misterinkjet.com/images/America/eagle-flag-6.jpg
-
For you? not to be.
-
Sure!!!!! Just remember the rule ... BYOB ... bring your own bed (I can supply the beer) I ain't sharing my air mattress with you. Oh and remember I have NO furniture or anything like that ... but I do have PLENTY of extra room so that won't be a problem ;) OH and no curds yet.
-
I thought about what could be causing your error (you posted above). Then realized where "sql.txt" comes in!!!!
-
HAHAHAAHA!!! I think I know your problem. Your current directory may not be in your command path. If your script file is sql.txt, run it like: ./sql.txt
