[Date Index]
[Thread Index]
[Author Index]
Re: Re: functions
Selwyn Hollis wrote:
>
> This is a pretty wild idea, but how about the following as a criterion
> for deeming a single-precision floating-point number between 0 and 1 to
> be "irrational": It's irrational if its base-10 form contains all 10
> digits, more precisely, if
>
> IrrationalQ[x_] := Length[Union[IntegerDigits[Round[10^16*x]]]] == 10
>
> returns True. Then
>
> grph = Plot[If[IrrationalQ[x], x, 0], {x, 0, 1}, PlotPoints -> 100]
>
> draws a graph that, with a little imagination, suggests what the graph
> of
> If[x is irrational, x, 0] could look like.
>
> Still better is
>
> Show[Graphics[{AbsolutePointSize[1.5], Point[#]} & /@
> (grph/.Graphics[{{Line[z_]}}, ___] -> z)]]
>
> This is all nonsense, of course, but fun nonetheless.
>
> Experiments show that IrrationalQ[Random[]] returns True with
> probability roughly 0.07. (Anybody have a clue why?)
>
> -----
> Selwyn Hollis
> http://www.math.armstrong.edu/faculty/hollis
> [...]
As to that experimental probability...
If you ignore the case where the leading digit is zero and disappears,
the probability is modelled as follows.
Let p[j] denote the probability that the first j digits contain all 10
digits (so obviously p[j]=0 for j<10).
We have
p[10] = Product[j/10, {j,1,9}];
Now p[11] = p[10] + probability that we need exactly 11 digits to get
all 10 possibilities. This means exactly one of the first ten digits
replicates an earlier digit. This arises if the second digit replicates
the first (probability 1/10), or the third replicates the second or
first (probability 2/10), etc. In Mathematica this would be given by
Sum[k[1]/10,{k[1],9}] * p[10]
We need exactly 12 digits if exactly two of the first eleven digits
replicate earlier digits. This is given by
Sum[k[1]/10*k[2]/10, {k[1],9}, {k[2],k[1],9}] * p[10]
In general we have:
productsum[j_Integer] := Module[
{k, vars, prod, iters},
vars = Array[k,j-10];
k[0] = 1;
prod = Apply[Times,vars]/10^(j-10);
iters = Map[{#,#[[0]][#[[1]]-1],9}&,vars];
Sum[prod,Evaluate[Apply[Sequence,iters]]]
]
(I'm sure this is not the cleanest way to code this).
p[j_Integer /; j>10] := p[j-1] + productsum[j]*p[10]
In[59]:= InputForm[p16 = p[16]]
Out[59]//InputForm= 10985907933/156250000000
In[60]:= N[p16]
Out[60]= 0.0703098
This pretty well replicates your experimental result.
By the way, those random decimals are double precision floats, not
single.
Daniel Lichtblau
Wolfram Research
**References**:
**functions**
*From:* lorenzo.keegan@handbag.com
**Re: functions**
*From:* Selwyn Hollis <sh2.7183@misspelled.erthlink.net>
Prev by Date:
**suppressing evaluation/simplification in Integrate**
Next by Date:
**Re: Re: typesetting fractions**
Previous by thread:
**Re: functions**
Next by thread:
**Re: functions**
| |