d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Math Problem > Question In Probability
Add Reply New Topic New Poll
Member
Posts: 3,401
Joined: Feb 7 2011
Gold: 8,195.00
Jan 8 2019 08:32am
Suppose f(n) produces a random natural number in [1, n] with uniform distribution.

Find P(f(f(n)) = x)
Member
Posts: 5,064
Joined: Feb 8 2016
Gold: 27,396.00
Jan 8 2019 02:55pm
Given you're asking this question I"m going to assume you have some basic knowledge of probability / notation used therein. LMK if you spot errors / have questions.

Let X ~ U(1,n) ##X is a random variable that is uniformly distributed across the integers [1,n]
Let Y | X = x ~ U(1,x).

Then, the density of Y (which tells you P(Y = y) = P(f(f(n)) = y)), (note I'm using y here while u used x but the exact symbol doesn't matter) is easily found using law of total probability:

P(Y = y) = \sum_{i=1}^n P(Y = y | X = x) P(X = x) ##law of total probability, note I'm using latex parlance to write the sums which may not register on jsp
= \sum_{i=1}^n (1/x) * (1/n) ##since the random variables above have uniform distributions
= (1/n) \sum_{i=1}^n (1/x)

I'm sort of confident the above answer is correct. However, it's a bit weird since \sum_{i=1}^n (1/x) doesn't have a closed form solution. You could write P(Y = y) = H_n/n where n is the nth harmonic number and that would be "correct". You could also leave it as is and that would be correct as well (assuming I didn't do something wrong). This expression is close to log(n)/n as well so that could be a nice approximation. Could be wrong so double check / think about this. Does the above density sum to 1?

Please gib fg

This post was edited by ogsarticuno on Jan 8 2019 03:09pm
Member
Posts: 16,662
Joined: Nov 24 2007
Gold: 15,245.00
Trader: Trusted
Jan 8 2019 03:43pm
Quote (ogsarticuno @ Jan 8 2019 09:55pm)
(...)

P(Y = y) = \sum_{i=1}^n P(Y = y | X = i) P(X = i)
= \sum_{i=y}^n (1/i) * (1/n)
= (1/n) \sum_{i=y}^n (1/i)

(...)


since P(Y = y | X = i) = 0 as soon as i < y.

Does it seem better like that ?

Also it's possible to replace your 'y' by the original 'x' :

P(Y = x) = \sum_{i=1}^n P(Y = x | X = i) P(X = i)
= \sum_{i=x}^n (1/i) * (1/n)
= (1/n) \sum_{i=x}^n (1/i)

And indeed, it sums to 1 (ouf !) :

Let S = sum_{x = 1}^{+infinity} P(Y = x).

S = sum_{x = 1}^n P(Y = x) since P(Y = x) = 0 as soon as x > n
S = sum_{x=1}^n (1/n) sum_{i=x}^n (1/i)
S = sum_{i=1}^n sum_{x=1}^i 1/(ni)
S = sum_{i=1}^n i/(ni)
S = sum_{i=1}^n (1/n)
S = n * (1/n)
S = 1
Member
Posts: 19,444
Joined: Mar 29 2006
Gold: 0.00
Jan 8 2019 06:19pm
Quote (feanur @ Jan 8 2019 09:43pm)
since P(Y = y | X = i) = 0 as soon as i < y.

Does it seem better like that ?

Also it's possible to replace your 'y' by the original 'x' :

P(Y = x) = \sum_{i=1}^n P(Y = x | X = i) P(X = i)
= \sum_{i=x}^n (1/i) * (1/n)
= (1/n) \sum_{i=x}^n (1/i)

And indeed, it sums to 1 (ouf !) :

Let S = sum_{x = 1}^{+infinity} P(Y = x).

S = sum_{x = 1}^n P(Y = x) since P(Y = x) = 0 as soon as x > n
S = sum_{x=1}^n (1/n) sum_{i=x}^n (1/i)
S = sum_{i=1}^n sum_{x=1}^i 1/(ni)
S = sum_{i=1}^n i/(ni)
S = sum_{i=1}^n (1/n)
S = n * (1/n)
S = 1


my brain .....
Member
Posts: 3,401
Joined: Feb 7 2011
Gold: 8,195.00
Jan 8 2019 11:57pm
Quote (feanur @ Jan 8 2019 03:43pm)
(1/n) \sum_{i=x}^n (1/i)


yeah this is what i got except offset a little

fun problem



This post was edited by otay on Jan 8 2019 11:58pm
Member
Posts: 3,401
Joined: Feb 7 2011
Gold: 8,195.00
Jan 8 2019 11:59pm
Quote (ogsarticuno @ Jan 8 2019 02:55pm)
Given you're asking this question I"m going to assume you have some basic knowledge of probability / notation used therein. LMK if you spot errors / have questions.


im a bit rusty, so i struggled to follow along tbh
Member
Posts: 16,662
Joined: Nov 24 2007
Gold: 15,245.00
Trader: Trusted
Jan 9 2019 01:29pm
Quote (otay @ Jan 9 2019 06:57am)
yeah this is what i got except offset a little

fun problem

https://i.imgur.com/7jRGWEZ.jpg


Your answer is correct. And it's exactly the same as above : in your final sum, just let k = n - i
When i is an integer from [0,n-x], then k belongs to [x,n] and your sum looks like :
(1/n) sum_{k=x}^n (1/k)

Did you write the text above yourself ? Then you have a beautiful writing !
Member
Posts: 3,401
Joined: Feb 7 2011
Gold: 8,195.00
Jan 9 2019 01:32pm
Quote (feanur @ Jan 9 2019 01:29pm)
Your answer is correct. And it's exactly the same as above : in your final sum, just let k = n - i
When i is an integer from [0,n-x], then k belongs to [x,n] and your sum looks like :
(1/n) sum_{k=x}^n (1/k)


yeah, thats what i meant

Quote (feanur @ Jan 9 2019 01:29pm)
Did you write the text above yourself ? Then you have a beautiful writing !


well thanks :D
Go Back To Homework Help Topic List
Add Reply New Topic New Poll