Given functions f(a,b) = random(a) < random(b) and g(a,b) = a < random(a+b)
which if of them is more likely to result into 1, if random(n) returns arbitrary number in range of [0;n)?
Justify your answer.
Name:
Anonymous2016-08-05 17:10
f = g, because a < random(a+b) = a-random(a) < random(b)
Name:
Anonymous2016-08-05 17:38
(defun f (a b) (if (< (random a) (random b)) 1 0))
(defun g (a b) (if (< a (random b)) 1 0))
(defun count-fn-one (fn up-to) "Counts how many times FN is 1" (loop for i from 1 to up-to summing (loop for j from 1 to up-to summing (funcall fn i j))))
g(a,b) = a < random(a+b) a < [0;a+b) a < [0;a) + [0;b) a - [0;a) < [0;b) [0;a) < [0;b)
f(a,b) = g(a,b) ``
Name:
Anonymous2016-08-06 17:12
>>3 This is incorrect for two reasons. One, you defined g incorrectly. It got random(a+b), not random(b). Two, it's only probability check for three different randoms. You should have generated random(a) and random(b) first, then feed them to simplified f and g functions*, knowing random(a+b) is equal to random(a)+random(b). Only then you would get realistic results.
* 'a = random(a) 'b = random(b) 'f('a,'b) = 'a < 'b 'g(a,'a+'b) = a < 'a+'b
/prog/ is now officially proven to be full of inborn retards incapable of solving even elementary school problems, with exception of maybe one or two visitors. No wonder you vote Trump.
>>29 Mexicans illegals don't have higher education. They work in fields or in construction. Programmers without educations usually do freelance web coding stuff and live in some cheap country, like Mexico itself (pro-tip: USA is not the cheapest country to live in).
Name:
Anonymous2016-08-06 21:56
>>32 Only Ukraine would be cheaper than Mexico and have passable IT infrastructure at the same time. Yet most people in Ukraine don't speak english, as they are being forced to learn russian instead. So huge economic opportunity lost.
Name:
Anonymous2016-08-06 22:00
what's the deal with insulting people who can't easily solve the problem?
is somebody insecure about their problem solving ability?
>>35 The problem with that claim is that most "fat shaming" doesn't promote a desire for self-improvement, it just promotes low self-worth. Pointing out that losing weight will make you healthier and make you feel better about yourself is one thing, but that's not the form that "fat shaming" usually takes.
random(a + b) = random(a) + random(b) <-- Unproven a < random(a) + random(b) = a - random(a) < random(b) = random(a) < random(b)
(defun random-a+b (n) "By how much larger is random(a+b) than random(a)+random(b)?" (float (/ (loop for a from 1 to n sum (loop for b from 1 to n summing (- (random (+ a b)) (+ (random a) (random b))))) (* n n))))
* (random-a+b 10000) 0.8115202
Name:
Anonymous2016-08-07 9:43
>>38 and..... lispers keep being reddit laughing-stock!