Statistics
| Revision:

root / branches / pthreads-737 / tests / multisimple / msimple1.tpl @ 766

History | View | Annotate | Download (994 Bytes)

1
//$Id: msimple1.tpl 742 2013-01-12 17:26:20Z jsibert $
2

    
3
DATA_SECTION
4
  !! ad_comm::change_datafile_name("msimple.dat");
5
  init_int nobs
6
  init_int nslaves
7

    
8
  matrix Y(1,nslaves,1,nobs)
9
  matrix x(1,nslaves,1,nobs)
10

    
11
 LOCAL_CALCS
12
    double A = 2.0;
13
    double B = 4.0;
14
    random_number_generator rng(101);
15
    dvector err(1,nobs);
16
    for (int i = 1; i <= nslaves; i++)
17
    {
18
       x(i).fill_randu(rng);
19
       x(i) *= 100.0;
20
       Y(i) = A*x(i) + B;
21
       err.fill_randn(rng);
22
       Y(i) += 5.0*err;
23
    }
24

    
25
PARAMETER_SECTION
26
  init_number a   
27
  init_number b   
28
  vector ff(1,nslaves)
29
  matrix pred_Y(1,nslaves,1,nobs)
30
  objective_function_value f
31

    
32
PRELIMINARY_CALCS_SECTION
33
  a = 1.0;
34
  b = 2.0;
35

    
36
PROCEDURE_SECTION
37
  for (int i=1;i<=nslaves;i++)
38
  {
39
      pred_Y(i) = a * x(i) +  b;
40
      ff(i) = norm2(pred_Y(i)-Y(i)); 
41
      ff(i) = nobs/2.*log(ff(i));    // make it a likelihood function so that
42
                                    // covariance matrix is correct
43
  }
44
  f = sum(ff);
45