Created
January 24, 2013 10:06
-
-
Save bssstudio/4619496 to your computer and use it in GitHub Desktop.
Expected number of subnodes of a randomly selected node in a tree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def propab(d: Int, n: Int, b: Int): Double = { | |
| Math.pow(b,d-1)/Math.pow(b,n) | |
| } | |
| def expected(n:Int, bf: Int): Double = { | |
| (1 to n).foldLeft(0.0)( (a:Double,b:Int) => a + (b*propab(b,n,bf)) ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment