All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
Maximum sum (Posted on 2004-07-29) Difficulty: 3 of 5
What's the probability that n random numbers from [0,1] will sum less than 1?

(For purists: "uniformly distributed, independent" random numbers are assumed.)

See The Solution Submitted by Federico Kereki    
Rating: 3.8333 (6 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Approximations were good enough for Archimedes :-) | Comment 3 of 10 |
My estimates agree with Charlie's. ("What a relief...", he says).
 
N=1, odds= 1.0
N=2, odds=0.49563
N=3, odds=0.16735
N=4, odds=0.04211
N=5, odds=0.00857
N=6, odds=0.00149
N=7,odds=0.00017
N=8, odds=0.00001
N >=9, odds=0

Visual Basic program used.

Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
    Sub Main()
        Randomize()
        Dim strstarttime As String
        Dim strendtime As String
        Dim strend As String
        Dim dblless As Double
        Dim dbltot As Double = 100000
        strstarttime = TimeOfDay
        Console.WriteLine("Start of execution: " & strstarttime)
        For index1 As Integer = 1 To 100
            gofigure(index1, dbltot, dblless)
            Console.WriteLine( _
            "For n=" & Str(index1) & _
            ", odds=" & Str(dblless / dbltot))
            Console.WriteLine("Please press ENTER to continue.")
            Console.ReadLine()
        Next
        strendtime = TimeOfDay
        Console.WriteLine(" ")
        Console.WriteLine("Start of execution: " & strstarttime)
        strendtime = TimeOfDay
        Console.WriteLine("End of execution: " & strendtime)
        strend = "?"
        Console.WriteLine(" ")
        While strend <> "X"
            Console.WriteLine("Please enter X to exit program...")
            strend = UCase(Console.ReadLine())
        End While
    End Sub

    Sub gofigure(ByRef index1, ByRef dbltot, ByRef dblless)
        Dim dblwork1 As Double
        Dim dblwork2 As Double
        dblless = 0
        For index2 As Integer = 0 To dbltot
            dblwork2 = 0
            For index3 As Integer = 1 To index1
                dblwork1 = _
                (((1000000000 - 0 + 1) * Rnd()) + 0) / 1000000000
                dblwork2 += dblwork1
            Next
            If dblwork2 < 1 Then
                dblless += 1
            End If
        Next
    End Sub
End Module


  Posted by Penny on 2004-07-29 09:41:01
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (25)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information