Android Tutorial Android Device Unique ID - Alternative to PhoneId

LucaMs

Expert
Licensed User
In that calculation you have nothing about possible matching.

You just calculated average distance between 2 neighbor numbers
from sorted list of 100,000 random generated intigers from interval [0, 2,147,483,648]

Lets say person X1 got one of 2,147,483,648 numbers.
Person X2 will get the same number with 1 / 2,147,483,648 chance = 0.0000000004656...
Person X2 will get different number with 2,147,483,647 / 2,147,483,648 chance = 0.9999999995343...

but we did't test all possible matching.
we tested only person X1 with person X2

we must test:

(X1 with X2) AND (X1 with X3) AND (X1 with X4) AND ... AND (X1 with X100,000)
AND
(X2 with X3) AND (X2 with X34 AND (X2 with X5) AND ... AND (X2 with X100,000)
AND
.
.
.
AND
(X99,999 with X100,000)

There is 4,999,950,000 possible matching (Binomial coefficient "100,000 choose 2")

So,
Probability that one pair have different numbers is:
2,147,483,647 / 2,147,483,648 chance = 0.9999999995343

Probability that all 4,999,950,000 pairs have different numbers is:
0.9999999995343^4,999,950,000=0.0974

If we take the complement of that:
Probability that there is at least one pair that have same numbers is:
1 - 0.0974 = 0.9026 = 90.26 % :eek:

Maybe contra intuitive but, like this,
similar "paradox" is that in group of just 23 people
greater chance is that there exist pair of two people that celebrates birthday
on same day than there doesn't exist such pair.
And here is 365 / 23 = 15.87 average days distance between 2 neighbor birthdays

Hope this helps! :)
Your answer is very complicated and at this time I have my usual headaches (also English does not help).

If you're right, a test is sufficient.

100 random pairs (or more, 100,000) and calculate how many of them are equal.
 

LucaMs

Expert
Licensed User
It runs 10 tests and count how many of them fails or not
total success will be around 50% (on 55,000)
total success will be around 10% (on 100,000)

WARNING: REALLY SLOW :D
I did not understand.

The app calculates how many times two "Id" calculated at random are equal in proportion to the number of attempts. Probably never.

The probability that they are equal is 1 / (2 ^ 31)!



[using an emulator it is very fast, much less than one second]



[P.S. ops, you were referring to your project]
 
Last edited:

danijel

Active Member
Licensed User
Ok, we don't understand each other.

The probability that two numbers are equal is 1 / (2 ^ 31)! - That's correct.
But if you have 100,000 users i'm trying to say that very often 99,998 users will get unique number and only 2 users will get the same number !
so not all users will have unique number and that Test is fail!
If happens that all 100,000 users get unique number that test is successful!

And i'm saying that in 90% cases Test will faill

Like in lottery... chance for one person to win is 1:15,000,000,000
but every month somebody score. How is that? - Lot's of people play.
 

LucaMs

Expert
Licensed User
I'm not so sure about this your statement:

"There is > 90% chance that 2 of 100,000 users will get the same number"

but you're right, it is preferable to use an alphanumeric code.
 

LucaMs

Expert
Licensed User
To be precise there is 90.25% chance that at least 2 of 100,000 users will get the same number.
Math is an exact science:

View attachment 32765
I'm not at all an expert in mathematics.

What is the operation represented by the position of the binomial coefficient?

(I do not know how to express well the question)

upload_2015-3-9_2-30-32.png
 

Shay

Well-Known Member
Licensed User
Using the code on first page (Erel) I cannot get ID from android tv device (getting 123456..)
and using the WIFI code I am getting 2:0:0:0:0... which is also not valid.
Any other way to get unique device id (especially from android tv devices?)
 

Informatix

Expert
Licensed User

LucaMs

Expert
Licensed User
Working method to get an unique ID:
https://stackoverflow.com/a/14893618
From that page:
  • Phone number/SIM card number (if available or just use zeros)
  • Android ID
  • Mac Address (if available or just use zeros)
So, if first and third element are zeros, you will use only Android ID. If it was enough, why should you use the other two?

Creating a rnd num (long) and saving it in the DirInternal is not a valid solution?
 

Informatix

Expert
Licensed User
From that page:
  • Phone number/SIM card number (if available or just use zeros)
  • Android ID
  • Mac Address (if available or just use zeros)
So, if first and third element are zeros, you will use only Android ID. If it was enough, why should you use the other two?

Creating a rnd num (long) and saving it in the DirInternal is not a valid solution?
I was in a bit of a hurry yesterday and I didn't elaborate. The idea to remember is that it is better to make an aggregate of several values than to simply rely on a single one. I implemented the proposed solution in my first application, My Playground, and I'm satisfied with it, but I didn't have a strict requirement.

Creating a random number that you save in a directory exposes you to the risk of hacking. Using the ID of someone else becomes pretty easy.
 
Top