clear
mode(2);

//Question 1.1
  bi=binomial(0.1,3)
  somme=sum(bi)
  
//Question 1.2
 (bi)*sqrt([0:3]/3)'
 
//Question 1.3
 function L=bern(X)
  n=length(X)-1
  for i=1:101
    M(i,:)=binomial((i-1)/100,n)
  end
  L=(M*(X'))'
endfunction

//Question1.4
X=[0:3]/3
Y=sqrt(X)
Z=bern(Y);
x=[0:100]/100;
//plot2d(x,sqrt(x))
//plot2d(x,Z,style=5)

//Question2
X=[0,1,3,4]
Y=[0,2,-1,0]
//plot2d(bern(X),bern(Y),style=5)
//plot2d(X,Y,style=-2)

////Question 3
//plot2d([],[],rect=[-1,-1,1,1])
//[c,x,y]=xclick();
//X=[x];
//Y=[y];
//n=0
//while modulo(c,3)==0
//  [c,x,y]=xclick();
// X=[X,x];
// Y=[Y,y];
// plot2d(bern(X),bern(Y),style=n)
//  plot2d(X,Y,style=-2)
// n=n+1;
//end

//Question 4
L=[]
F=exp([0:100]/100);
for n=5:30
  X=(0:n)/n;
  e=max(bern(exp(X))-F);
  L=[L,e];
end
//plot2d(5:30,L)

