- #1
delcypher
- 5
- 0
Minimising a function related to a "Bloom Filter"
I'm looking at a problem that requires me to find [itex]k[/itex] that minimises the function [itex]f[/itex]. Where [itex]n,m[/itex] are to be treated as constants.
Although not needed for this problem the context is that the function [itex]f[/itex] approximately describes the probability of "finding a false positive" when using the bloom filter data structure (computer science). See http://en.wikipedia.org/wiki/Bloom_filter#Probability_of_false_positives
[itex]f(k) = (1 - e^{\frac{-kn}{m}})^k[/itex]
I already know what the answer should be. Which is the [itex]k[/itex] that minimises [itex]f[/itex] is given by
[itex]k_{\text{min}} = \frac{m}{n} \ln(2)[/itex]
What I want to find out is a good way of getting there. I found a way but it is incomplete because it requires me to know the form of the answer and to use observation to solve for a particular value. So what I'd like to know is
My plan is to differentiate [itex]f[/itex] with respect to [itex]k[/itex] and set to 0 and then solve for [itex]k[/itex].
Firstly I rewrite [itex]f[/itex].
[itex] f = e^{k \ln{\left(1 - e^{\frac{-kn}{m}}\right) }}[/itex]
[itex] \ln{f} = k \ln{ ( 1 - e^{\frac{-kn}{m}}) }[/itex]
and observe that minimising [itex]f[/itex] is equivalent to minimising [itex]\ln{f}[/itex]
Now via the product rules and chain rule...
[itex] \frac{d \ln{f}}{dk} =
\ln{(1 - e^{\frac{-kn}{m}} )} +
\frac{kn e^{ \frac{-kn}{m} } }{m (1 - e^{\frac{-kn}{m}}) }
=0
[/itex]
I now make the following substitution to make the equations easier to write
[itex] a = \frac{kn}{m} [/itex]
so...
[itex] \frac{d \ln{f}}{dk} =
\ln{(1 - e^{-a} )} +
\frac{a e^{-a} }{(1 - e^{-a}) }
=0
[/itex]
So now I'm solving for a. I now rewrite the second term using the following...
[itex] \frac{a e^{-a} }{(1 - e^{-a}) } =
\ln{(e^{ \frac{a e^{-a} }{(1 - e^{-a}) } } )}
[/itex]
To give...
[itex]
\ln{ \left( (1 - e^{-a} ) e^{ \frac{a e^{-a} }{(1 - e^{-a}) } } \right) } = 0
[/itex]
Now re-arranging...
[itex] (1 - e^{-a} ) e^{ \frac{a e^{-a} }{(1 - e^{-a}) } } = 1 [/itex]
Now because I know what the answer is supposed to be it hints to me that I should try a form of [itex]a[/itex] such that [itex]a = \ln{j}[/itex] where [itex]j[/itex] is to be found which would give a solution of
[itex] k_{\text{min}} = \frac{m}{n} \ln{j} [/itex]
Substituting that in and rearranging gives
[itex] ( 1 - \frac{1}{j}) j^{\frac{1}{j-1}} = 1 [/itex]
This is where I get stuck. I can't think of a way to solve the above equation for [itex]j[/itex]. By observation I can see that [itex]j = 2[/itex] solves it as expected but I don't know how to show that. I can see by plotting it (via GnuPlot) that [itex]j=2[/itex] is the only solution. I also found that "Wolfram Alpha" was able to solve the equation although it wouldn't explain to me how it did so.Any ideas?
Homework Statement
I'm looking at a problem that requires me to find [itex]k[/itex] that minimises the function [itex]f[/itex]. Where [itex]n,m[/itex] are to be treated as constants.
Although not needed for this problem the context is that the function [itex]f[/itex] approximately describes the probability of "finding a false positive" when using the bloom filter data structure (computer science). See http://en.wikipedia.org/wiki/Bloom_filter#Probability_of_false_positives
Homework Equations
[itex]f(k) = (1 - e^{\frac{-kn}{m}})^k[/itex]
I already know what the answer should be. Which is the [itex]k[/itex] that minimises [itex]f[/itex] is given by
[itex]k_{\text{min}} = \frac{m}{n} \ln(2)[/itex]
What I want to find out is a good way of getting there. I found a way but it is incomplete because it requires me to know the form of the answer and to use observation to solve for a particular value. So what I'd like to know is
- Is there a way of completing my proof given later that doesn't require me to use observation (to find [itex]j[/itex])?
- Is there a better way of approaching the problem? I may of gone the long way round proving this.
The Attempt at a Solution
My plan is to differentiate [itex]f[/itex] with respect to [itex]k[/itex] and set to 0 and then solve for [itex]k[/itex].
Firstly I rewrite [itex]f[/itex].
[itex] f = e^{k \ln{\left(1 - e^{\frac{-kn}{m}}\right) }}[/itex]
[itex] \ln{f} = k \ln{ ( 1 - e^{\frac{-kn}{m}}) }[/itex]
and observe that minimising [itex]f[/itex] is equivalent to minimising [itex]\ln{f}[/itex]
Now via the product rules and chain rule...
[itex] \frac{d \ln{f}}{dk} =
\ln{(1 - e^{\frac{-kn}{m}} )} +
\frac{kn e^{ \frac{-kn}{m} } }{m (1 - e^{\frac{-kn}{m}}) }
=0
[/itex]
I now make the following substitution to make the equations easier to write
[itex] a = \frac{kn}{m} [/itex]
so...
[itex] \frac{d \ln{f}}{dk} =
\ln{(1 - e^{-a} )} +
\frac{a e^{-a} }{(1 - e^{-a}) }
=0
[/itex]
So now I'm solving for a. I now rewrite the second term using the following...
[itex] \frac{a e^{-a} }{(1 - e^{-a}) } =
\ln{(e^{ \frac{a e^{-a} }{(1 - e^{-a}) } } )}
[/itex]
To give...
[itex]
\ln{ \left( (1 - e^{-a} ) e^{ \frac{a e^{-a} }{(1 - e^{-a}) } } \right) } = 0
[/itex]
Now re-arranging...
[itex] (1 - e^{-a} ) e^{ \frac{a e^{-a} }{(1 - e^{-a}) } } = 1 [/itex]
Now because I know what the answer is supposed to be it hints to me that I should try a form of [itex]a[/itex] such that [itex]a = \ln{j}[/itex] where [itex]j[/itex] is to be found which would give a solution of
[itex] k_{\text{min}} = \frac{m}{n} \ln{j} [/itex]
Substituting that in and rearranging gives
[itex] ( 1 - \frac{1}{j}) j^{\frac{1}{j-1}} = 1 [/itex]
This is where I get stuck. I can't think of a way to solve the above equation for [itex]j[/itex]. By observation I can see that [itex]j = 2[/itex] solves it as expected but I don't know how to show that. I can see by plotting it (via GnuPlot) that [itex]j=2[/itex] is the only solution. I also found that "Wolfram Alpha" was able to solve the equation although it wouldn't explain to me how it did so.Any ideas?