My point was simply that if you want me to select a random number, but
hands me of list of numbers I'm not allowed to pick, it can't really
be random. If you limit the length of the number (this is programming
- there is always a limit) there is a maximum of how many "random"
numbers I can give you ;-)

On Wed, Jun 19, 2013 at 2:25 PM, Kristopher Micinski
<[email protected]> wrote:
> That's not true, it can still be random: just over a different state
> space. (In particular [0-9]^n \ {alpha^n | any character is repeated
> in alpha})
>
> OP: you could pull out a statistics book and read about random events,
> how to generate them using coins, etc...  But the easiest way is to
> generate a random number, add it to the list if it's not already in
> the list, etc...  The uniformity argument works based on the invariant
> that at each stage the next number you choose to "fix" the rest of
> your choices is random, hence the distribution remains random.
>
> # let assemble_random_nums len =
>     let rand () = (Random.int 9) + 1 in
>     let rec h l     = function
>       | 0 -> l
>       | i -> let r = rand () in if (List.mem r l) then (h l i) else (h
> (r::l) (i-1))
>     in
>     h [] len;;
> val assemble_random_nums : int -> int list = <fun>
> # assemble_random_nums 4;;
> - : int list = [1; 8; 3; 9]
> # assemble_random_nums 4;;
> - : int list = [2; 9; 5; 4]
> # assemble_random_nums 4;;
>
> Kris
>
> On Wed, Jun 19, 2013 at 7:03 AM, Michael Banzon <[email protected]> wrote:
>> First: This isn't really a question related to Android development.
>>
>> Second: Random unique numbers between 1 and 9 (including both
>> extremes) is a set of 9 numbers (I really hope that we are talking
>> about integers and not real/floating point numbers).
>>
>> Third: If you request a unique sequence of numbers 1 to 9 it can't be
>> random as it would include a check for uniqueness that would remove
>> some degree of randomness.
>>
>> On Wed, Jun 19, 2013 at 11:56 AM, vamshi ch <[email protected]> wrote:
>>> Hi All,
>>>
>>>      In my application i want to generate random numbers between 1 to 9 and
>>> that is unique. once i get the random number that should not be repeated for
>>> any one, any where and for me also. it's similar to OTP(one time password)
>>> but some time OTP will be repeated and that is alphanumerical but in my case
>>> that should not be happen and i need numbers only.
>>>
>>> Please can you tell me what is the approach to achieve it. Please help out
>>> of this..
>>>
>>>
>>>    Please share the code if you have any regarding this..
>>>
>>> --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "Android Developers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>>
>>
>> --
>> Michael Banzon
>> http://michaelbanzon.com/
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups 
>> "Android Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups 
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Michael Banzon
http://michaelbanzon.com/

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to