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

x is a randomly chosen hexadecimal real number on the interval (0, (10)16)

Determine the probability of each of the following:

(i) x and 3x have the same first digit.

(ii) x and x3 have the same first digit.

(iii) x3 and 3x have the same first digit.

(iv) x, x3 and 3x have the same first digit.

*** “First digit” denotes the first nonzero digit of the number when expressed in hexadecimal form.

 No Solution Yet Submitted by K Sengupta Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Simulations for all parts | Comment 3 of 6 |
The below program invokes the randomization initialization when the user clicks the start button, which I did 10 times. At 100,000 trials per click, there were a million trials, hopefully better randomized than if one sequence of a million trials were done without interrupting the randomization process at random.

DefDbl A-Z
Dim crlf\$, type1, type2, type3, type4, trials

Private Sub Command1_Click()
Randomize Timer
For tr = 1 To 100000
DoEvents
x = 16 * Rnd(1): xdig\$ = firstdig\$(x)
x3 = x ^ 3: x3dig\$ = firstdig\$(x3)
threex = 3 ^ x: threexdig\$ = firstdig\$(threex)
If xdig = threexdig Then type1 = type1 + 1
If xdig = x3dig Then type2 = type2 + 1
If threexdig = x3dig Then type3 = type3 + 1
If xdig = threexdig And xdig = x3dig Then type4 = type4 + 1
trials = trials + 1
Next tr
Text1.Text = Text1.Text & mform(type1 / trials, " 0.0000000000") & mform(type2 / trials, " 0.0000000000")
Text1.Text = Text1.Text & mform(type3 / trials, " 0.0000000000") & mform(type4 / trials, " 0.0000000000") & crlf
End Sub

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

x = x

End Sub

Function firstdig\$(n)
s\$ = hexreal\$(n)
For i = 1 To Len(s\$)
If InStr("123456789abcdef", Mid(s, i, 1)) > 0 Then Exit For
Next i
firstdig\$ = Mid(s, i, 1)
End Function

Function hexreal\$(n)
intpart = Int(n)
fracpart = n - intpart
h\$ = "."
While intpart > 0
q = Int(intpart / 16)
r = intpart - q * 16
intpart = q
h = Mid("0123456789abcdef", r + 1, 1) + h
Wend
While fracpart > 0
m = fracpart * 16
d = Int(m)
fracpart = m - d
h = h + Mid("0123456789abcdef", d + 1, 1)
Wend
hexreal\$ = h
End Function

Function mform\$(x, t\$)
a\$ = Format\$(x, t\$)
If Len(a\$) < Len(t\$) Then a\$ = Space\$(Len(t\$) - Len(a\$)) & a\$
mform\$ = a\$
End Function

The first row below represents the statistics based on the first 100,000 trials.  Each successive row adds in the results of the next 100,000, so that the final row represents the results of a million trials.

0.0447300000 0.0838700000 0.1664200000 0.0102400000
0.0441550000 0.0841100000 0.1658800000 0.0101700000
0.0440300000 0.0847200000 0.1654000000 0.0104800000
0.0439425000 0.0846525000 0.1654300000 0.0105675000
0.0440080000 0.0844860000 0.1653320000 0.0105520000
0.0439966667 0.0844466667 0.1654616667 0.0106216667
0.0439528571 0.0845685714 0.1655300000 0.0105814286
0.0438562500 0.0846700000 0.1655200000 0.0105325000
0.0439455556 0.0847811111 0.1653211111 0.0105255556
0.0438500000 0.0847820000 0.1653790000 0.0105160000

In the final tally 43,850 out of the million trials got a hit for situation (i), 84,782 hit situation (ii), 165,379 hit situation (iii) and 10,516 hit all (iv).

 Posted by Charlie on 2016-06-19 21:25:11

 Search: Search body:
Forums (3)