Blame view

Giac_maj/giac-1.4.9/examples/simulation/deplacement 1.29 KB
6663b6c9   adorian   projet complet av...
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  parcours() :={
    local T,r;
    T:=0;
    r:=rand(2);
    for (k:=1;k<6;k++){
      if (r==1){
        T:=T+1;
      }
      r:=rand(2);
    }
    return(T);
  }; 
  parcoursim(n) :={
    local T,r,A;
    A:=[0,0,0,0,0,0];
    for (j:=1;j<n+1;j++){
      r:=rand(2);
      T:=0;
      for (k:=1;k<6;k++){
        if (r==1){
          T:=T+1;
        }    
      r:=rand(2);
      }
    A[T]:=A[T]+1;
    }
    xyztrange(-0.5,5.2,-0.1,16.0,-10.0,10.0,-10.0,-10.0,
              -0.5,5.2,-0.1,16.0,1);
    switch_axes(NULL);
    return([A,segment(0,i*A[0]),segment(1,1+i*A[1]),
       segment(2,2+i*A[2]),segment(3,3+i*A[3]),segment(4,4+i*A[4]),
       segment(5,5+i*A[5])]);
  }; 
  parcours2() :={
    local X,Y,r;
    X:=0;
    Y:=0;
    r:=rand(2);
    for (k:=1;k<6;k++){
      if (r==1){
         X:=X+1;
      } else {
         Y:=Y+1;
      }
      r:=rand(2);
    }
    return([X,Y]);
  }; 
  parcoursim2(n) :={
    local X,Y,r,A;
    A:=[0,0,0,0,0,0];
    for (j:=1;j<n+1;j++){
      r:=rand(2);
      X:=0;
      Y:=0;
      for (k:=1;k<6;k++){
        if (r==1){
          X:=X+1;
        } else {
          Y:=Y+1;
        }
      r:=rand(2);
      }
    A[X]:=A[X]+1;
    }
    switch_axes(NULL);
    xyztrange(-0.5,5.2,-0.1,16.0,-10.0,10.0,-10.0,-10.0,
              -0.5,5.2,-0.1,16.0,1);
    
    return([A,segment(0,i*A[0]),segment(1,1+i*A[1]),
       segment(2,2+i*A[2]),segment(3,3+i*A[3]),segment(4,4+i*A[4]),
       segment(5,5+i*A[5])]);
  };