Question: Why does the tilde operator sometimes fail?

Hi, 

While trying to convert into integers a sample S drawn from a binomial distribution,  I've observed that  round~(S) didn't do the job while map(round, S) did it.

First question: why the first syntax and the second one are not equivalent on this case?

I investigated a little bit further by applying round~ on a row vector T of Hfloats (thus T and S are "identical")

Second question: While  round~(S) doesn't work but round~(T) does?


 

restart

S := Statistics:-Sample(Binomial(10, 0.5), 2);
round~(S);      # Why round~(S) doesn't return integers
map(round, S);  # but map(round, S) does?

lprint(S)

S := Vector[row](2, {(1) = 6.0, (2) = 7.0}, datatype = float[8])

 

Vector[row]([6., 7.])

 

Vector[row]([6, 7])

 

Vector[row](2, {1 = HFloat(6.), 2 = HFloat(7.)}, datatype = float[8], storage = rectangular, order = Fortran_order, shape = [])

 

# Evaluation of round~(T) on a vector of Hfloats



T := Vector[row](2, [HFloat(6.), HFloat(3.)]);
lprint(S);
round~(T);   # round~(T) returns integers,
             

T := Vector[row](2, {(1) = HFloat(6.0), (2) = HFloat(3.0)})

 

Vector[row](2, {1 = HFloat(6.), 2 = HFloat(7.)}, datatype = float[8], storage = rectangular, order = Fortran_order, shape = [])

 

Vector[row]([6, 3])

(1)

 


 

Download Tilde_versus_map.mw

 

Please Wait...