/All/
|
index
catalog
recent
update
post
|
/math/
/tech/
/anime/
/misc/
/free/
/meta/
|
Guide
dark
mod
Log
P100205
Random functions
Tue 2024-07-09 00:49:41
link
reply
ae83b515720c0021c74f00c77b92e013199c95972b48fbbb55ca9bf937aa09ef.png
77.5 KiB 2880x1288
Let A be finite.
Consider a uniformly distributed random function f: A->A.
How does
[tex:
N(n) := E[|f
^
n
(A)|]
]
vary with n and |A|?
P100249
Tue 2024-07-09 08:27:41
link
reply
Is
[tex:
A
\in
A
]
? It isn't possible if A is finite, and that's what you imply by calling f(A)
Or is f(A) shorthand for
[tex:
{f(a)
\forall
a
\in
A}
]
?
"random function" is poorly defined as well (it could refer to a stochastic process), but I will assume that f is a random element of (A->A)
Let's see:
for 0<k≤A, we have
[tex:
P
_
k
]
= P(|f(A)|≤k) =
[tex:
\frac
{
|A|!
}
{
k!(|A|-k)!
}
(
\frac
{
k
}
{
|A|
}
)
^
{
|A|
}
]
for k≤0, we have P(|f(A)|≤k) = 0
and for k>A, we have P(|f(A)|≤k) = 1
Therefore,
E[|f(A)|] =
[tex:
\sum
_
{
k=1
}
^
{
|A|
}
k(P
_
k
- P
_
{
k-1
}
)
]
= |A| -
[tex:
\sum
_
{
k=1
}
^
{
|A|-1
}
P
_
k
]
For the induction, we would need to find
[tex:
P
_
{
|f(A)|=k
_
1
}
]
(|f²(A)|=k_2). I might do it later
Referenced by:
P100252
P100252
Tue 2024-07-09 08:50:45
link
reply
P100249
>Or is f(A) shorthand for
[tex:
{f(a)
\forall
a
\in
A}
]
?
Yes, the image.
>I will assume that f is a random element of (A->A)
Yes.
>we would need to find
[tex:
P
_
{
|f(A)|=k
_
1
}
]
(|f²(A)|=k_2).
I don't think the same method will work again. The distribution of f given f(A) is not just no longer uniform on A, but likely not uniform on f(A).
One nice fact is that in the limit for large |A|,
[tex:
\frac
{
|A\f(A)|
}
{
|A|
}
=
\frac
{
1
}
{
e
}
]
.
P100255
Tue 2024-07-09 09:53:38
link
reply
>Yes, the image.
I don't see how the image relate to your problem. Would you mind explaining it?
>I don't think the same method will work again
I guess not. Not sure how to go about it then
>One nice fact is that in the limit for large |A|,
[tex:
\frac
{
|A\f(A)|
}
{
|A|
}
=
\frac
{
1
}
{
e
}
]
.
Really? that's funny. Where is that coming from?
[tex:
\sum
_
{
k=1
}
^
{
|A|-1
}
\frac
{
(|A|-1)!
}
{
k!(|A|-k)!
}
(
\frac
{
k
}
{
|A|
}
)
^
{
|A|
}
]
Referenced by:
P100257
P100257
Tue 2024-07-09 10:02:00
link
reply
P100255
>I don't see how the image relate to your problem. Would you mind explaining it?
f(A) is the image of f.
>Where is that coming from?
For some a∈A,
[tex:
lim
_
{
|A|->∞
}
P(a∉f(A)) = lim
_
{
|A|->∞
}
(1 -
\frac
{
1
}
{
n
}
)
^
{
n
}
=
\frac
{
1
}
{
e
}
]
.
Referenced by:
P100258
P100258
Tue 2024-07-09 10:02:44
link
reply
P100257
(n = |A|)
P100264
Tue 2024-07-09 12:59:09
link
reply
Is f^n f composed with itself n times?
P100270
Tue 2024-07-09 16:11:28
link
reply
9754f7dc6ca38d248ad9112e84ac06b8af61889fa5d9b7e32650dc69b3e75366.jpg
562 KiB 1200x1800
>One nice fact is that in the limit for large |A|,
[tex:
\frac
{
|A\f(A)|
}
{
|A|
}
=
\frac
{
1
}
{
e
}
]
.
Sounds similar to derangements (not the schizo kind).
Referenced by:
P100579
P101242
Tue 2024-07-16 07:06:00
link
reply
I think I have a simple way to calculate it for the case
[tex:
n
\geq
|A|-1
]
. This is the case where you are guaranteed to have reached a loop. The idea is that you can just multiply |A| by the probability any given point
[tex:
x
\in
A
]
is part of a loop.
You have a probability of
[tex:
\frac
{
1
}
{
|A|
}
]
that f(x) = x and a probability
[tex:
\frac
{
|A|-1
}
{
|A|
}
]
that it maps to some other point.
In the case that
[tex:
f(x)
\neq
x
]
, you have a probability
[tex:
\frac
{
1
}
{
|A|
}
]
that f(f(x)) = x, giving you a loop of which x is a part, a probability
[tex:
\frac
{
1
}
{
|A|
}
]
that f(f(x)) = f(x), giving you a loop of which x is not a part, and a probability
[tex:
\frac
{
|A|-2
}
{
|A|
}
]
that f(f(x)) goes to a third point.
We can continue this: In the case that x, ...
[tex:
f
^
k
(x)
]
are all distinct, there is a probability
[tex:
\frac
{
1
}
{
|A|
}
]
that
[tex:
f
^
{
k+1
}
(x) = x
]
, making x part of the loop, a probability
[tex:
\frac
{
k
}
{
|A|
}
]
that
[tex:
f
^
{
k+1
}
(x)
]
is some prior point, making a loop of which x is not a part, and a probability
[tex:
\frac
{
|A|-(k+1)
}
{
|A|
}
]
of going to yet another point not visited yet.
For |A| = 4 the probability x is part of a loop is
[tex:
\frac
{
1
}
{
4
}
+
\frac
{
3
}
{
4
}
\frac
{
1
}
{
4
}
+
\frac
{
3
}
{
4
}
\frac
{
2
}
{
4
}
\frac
{
1
}
{
4
}
+
\frac
{
3
}
{
4
}
\frac
{
2
}
{
4
}
\frac
{
1
}
{
4
}
\frac
{
1
}
{
4
}
]
and therefore the expected number of points that are part of a loop is
[tex:
1 +
\frac
{
3
}
{
4
}
+
\frac
{
3
}
{
4
}
\frac
{
2
}
{
4
}
+
\frac
{
3
}
{
4
}
\frac
{
2
}
{
4
}
\frac
{
1
}
{
4
}
]
which can be rewritten in the form
[tex:
1 +
\frac
{
3
}
{
4
}
(1 +
\frac
{
2
}
{
4
}
(1 +
\frac
{
1
}
{
4
}
))
]
.
You can calculate it with
def f(a):
e = 1
for k in range(1,a):
e = e * Fraction(k,a) + 1
return e
or the equivalent float version if you just want a fast approximation. For large |A| it seems to be proportional to
[tex:
\sqrt
(|A|)
]
.
https://oeis.org/A001865
is related; it is this function multiplied by
[tex:
|A|
^
{
|A|-1
}
]
.
Referenced by:
P101244
P101244
Tue 2024-07-16 08:04:13
link
reply
P101242
>or the equivalent float version if you just want a fast approximation. For large |A| it seems to be proportional to
[tex:
\sqrt
(|A|)
]
.
Makes sense, it is like a birthday problem.
Given this, I expect the distribution becomes mostly loops quickly, taking near
[tex:
ln(|A|)
]
steps.
P101342
Wed 2024-07-17 19:05:27
link
reply
I wrote a little script to calculate some of the values (times
[tex:
|A|
^
{
|A|
}
]
):
-----------------------------------------
from itertools import product
for m in range(1,8):
count = [0]*m
for f in product(range(m), repeat=m):
xs = set(range(m))
for n in range(m):
count[n] += len(xs)
xs = set(f[x] for x in xs)
print(count)
-----------------------------------------
[1]
[8, 6]
[81, 57, 51]
[1024, 700, 592, 568]
[15625, 10505, 8625, 7965, 7845]
[279936, 186186, 150096, 134856, 130176, 129456]
[5764801, 3805249, 3029257, 2670367, 2528407, 2490607, 2485567]
-----------------------------------------
With enough transformations I was able to find something related in OEIS:
https://oeis.org/A225213
-----------------------------------------
from itertools import product
from fractions import Fraction
def div(x,y):
return x//y if x%y==0 else Fraction(x,y)
for m in range(1,8):
count = [0]*m
for f in product(range(m), repeat=m):
xs = set(range(m))
for n in range(m):
count[n] += len(xs)
xs = set(f[x] for x in xs)
diffs = [a-b for a,b in zip(count[:-1],count[1:])]
print([div(d,m*(m-1)) for d in diffs])
-----------------------------------------
[]
[1]
[4, 1]
[27, 9, 2]
[256, 94, 33, 6]
[3125, 1203, 508, 156, 24]
[46656, 18476, 8545, 3380, 900, 120]
-----------------------------------------
Referenced by:
P118643
Mod Controls:
x
Reason: