Lorenzo Isella <lorenzo.isella <at> gmail.com> writes:

> 
> Dear All,
> I am given a time series such at, at every time t_i, I am given a set
> of data (every element of the set is just an integer number).
> What I need is an injective function able to map every set into a
> number (possibly an integer number, but that is not engraved in the
> stone). Does anybody know how to achieve that?

In set theory you learn about the function that assigns to a set of integers
(i1, ..., in) the integer p1^i1 * ... * pn^in, where p1, ... is the sequence
of primes. In practice, unfortunately, this will lead to too large numbers.

I would recommend the 'digest' package that provides hashing functions such
as 'md5', etc., thanks to Dirk Eddelbuettel. It is injective enough and 
returns character strings of fixed length.

Hans Werner

> Cheers
> 
> Lorenzo
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to