Is there any reason you are using 10 o. instead of | ?

Marshall

________________________________________
From: [email protected] [[email protected]] On 
Behalf Of Sherlock, Ric [[email protected]]
Sent: Tuesday, September 21, 2010 5:16 AM
To: Programming forum
Subject: Re: [Jprogramming] Rescale data

Thanks guys,
The following combines the functionality/brevity of versions to date:

rescale=:3 :0
  1 rescale y
:
  'data xtrm'=. 2{.boxopen y
  'lowX magX lowY magY'=. (2{.x) ,&(-~/\@(<./,>./)) 10 o. xtrm,,data
  lowX+magX*(data-lowY)%magY
)

   rescale 4 1 9 5 3.5 7             NB. obtains min & max from data
0.375 0 1 0.5 0.3125 0.75
   rescale 4 1 9 5 3.5 7;0 10        NB. give min & max possible vals if not in 
data
0.4 0.1 0.9 0.5 0.35 0.7
   15 rescale 4 1 9 5 3.5 7;0 10     NB. "out-of-10" to "out-of-15"
6 1.5 13.5 7.5 5.25 10.5
   _5 10 rescale 4 1 9 5 3.5 7;0 10  NB. "out-of-10" to "from _5 to 10"
1 _3.5 8.5 2.5 0.25 5.5

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to