whimed:

Usage Arguments Examples

Usage

1
whimed(a, iw, n)

Arguments

a
iw
n

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (a, iw, n) 
{
    acand = 0
    iwcand = 0
    nn = n
    wtotal = sum(iw[1:nn])
    wrest = 0
    IsFound = 0
    while (IsFound == 0) {
        trial = pull(a, nn, floor(nn/2) + 1)
        wleft = sum(iw[c(a[1:nn] < trial, rep(F, n - nn))])
        wright = sum(iw[c(a[1:nn] > trial, rep(F, n - nn))])
        wmid = sum(iw[c(a[1:nn] == trial, rep(F, n - nn))])
        if ((2 * wrest + 2 * wleft) > wtotal) {
            i = c(a[1:nn] < trial, rep(F, n - nn))
            acand = a[i]
            iwcand = iw[i]
            nn = length(acand)
        }
        else {
            if ((2 * wrest + 2 * wleft + 2 * wmid) > wtotal) {
                whmed = trial
                IsFound = 1
            }
            else {
                i = c(a[1:nn] > trial, rep(F, n - nn))
                acand = a[i]
                iwcand = iw[i]
                nn = length(acand)
                wrest = wrest + wleft + wmid
            }
        }
        a[1:nn] = acand[1:nn]
        iw[1:nn] = iwcand[1:nn]
    }
    whmed
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.