Article View: aus.stats.s
Article #202Multi step closely matching element
From: jae ryu
Date: Tue, 22 Jun 2004 22:04
Date: Tue, 22 Jun 2004 22:04
46 lines
1805 bytes
1805 bytes
Hi..S+ Users:
I have data set below
x<-c(22,10,12,32,20)
> x
[1] 22 10 12 32 20
but y and z are matrix as follow.
First col represents probability and second col represents values.
>y<-matrix(c(0.1,.2,.3,.4,.5,.6,5,10,15,20,25,30),6,2)
>y
[,1] [,2]
[1,] 0.1 5
[2,] 0.2 10
[3,] 0.3 15
[4,] 0.4 20
[5,] 0.5 25
[6,] 0.6 30
>z<-matrix(c(.05,.1,.25,.5,.65,.7,.8,.9,2,6,8,10,17,22,35,40),8,2)
>z
[,1] [,2]
[1,] 0.05 2
[2,] 0.10 6
[3,] 0.25 8
[4,] 0.50 10
[5,] 0.65 17
[6,] 0.70 22
[7,] 0.80 35
[8,] 0.90 40
I want to find, for each x, which value of z is closest to each value
of x via y value.
For example,
x=12,
The result I am looing for would be -
Z=8.
Because the closest value of y to x=8 would be y=10, the probability
corresponding to y=10 would be 0.2.
then, the closest probability of z to the probability(0.2) of y=10
would be 0.25, so the final value of z would be 8
Any comment appreciated.
Jae Ryu
Civil and Environmental Eng.
Univ. of Wash. Seattle, WA
Technical Details
Message-ID:
<fcfd1720.0406221349.220b200@posting.google.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa931,fde545c31d017126,start X-Google-Attributes: gidfa931,public Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mail From: chunrima@hotmail.com (jae ryu) Newsgroups: aus.stats.s Subject: Multi step closely matching element Date: 22 Jun 2004 15:04:10 -0700 Organization: http://groups.google.com Lines: 46 Message-ID: <fcfd1720.0406221349.220b200@posting.google.com> NNTP-Posting-Host: 128.95.220.157 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1087941864 19937 127.0.0.1 (22 Jun 2004 22:04:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 22 Jun 2004 22:04:24 +0000 (UTC)