Harj. 12 AV

5.12.2001 HA

1.

> restart:

Warning, the name changecoords has been redefined

> f:=x->mu^x/x!*exp(-mu);

f := proc (x) options operator, arrow; mu^x*exp(-mu...

> 1-sum(f(x),x=0..1);subs(mu=1/2,%);evalf(%);

1-exp(-mu)-mu*exp(-mu)

1-3/2*exp(-1/2)

.902040104e-1

2.

> restart:

Warning, the name changecoords has been redefined

> f:=x->mu^x/x!*exp(-mu);

f := proc (x) options operator, arrow; mu^x*exp(-mu...

> P_alle_5:=sum(f(x),x=0..4);subs(mu=5,%);evalf(%);

P_alle_5 := exp(-mu)+mu*exp(-mu)+1/2*mu^2*exp(-mu)+...

523/8*exp(-5)

.4404932851

Nämä olisivat sopineet olemaan a)- ja b)-kohta samasta tehtävästä, mutta olkoon kompensaationa menneistä työläisyyksistä.

3.

Pohdiskellaan hieman Poissonin jakaumaa tässä yhteydessä KRE exe 3:n s. 1082 hengessä.

Siinä otetaan esimerkisi parkkipaikka, johon tulee keskimäärin 2 autoa minuutissa. Kysytään, millä todennäköisyydellä satunnaisesti valitun minuutin aikana saapuu x autoa

(tai jokin vastaava kysmys, johon jakaumafunktion avulla voidaan vastata).

Yleisemmin voidaan ottaa 2:n auton sijaan mu

autoa.

Jaetaan 1 min aikaväli pieniin osiin, n kpl. Todennäköisyys, että näistä keskimäärin mu :sta sisään tulevasta autosta jokin osuu tietylle osavälille : p = mu/n

Tilannetta voidaan ajatella toistokokeena, jossa näitä pieniä aikavälejä vedetään aikasäkistä.

Näin saadaan

> f:=x->B(n,x)*p^x*(1-p)^(n-x); # B on binomikerroin

f := proc (x) options operator, arrow; B(n,x)*p^x*(...

Kun n kasvaa, niin jakauma lähenee Poissonia ( mu = n*p ).

Sitten varsinaiseen tehtävään: Otetaan tämä exa 3 lähtökohdaksi.

> restart: with(combinat): alias(B=binomial):

Warning, the name changecoords has been redefined

Warning, the protected name Chi has been redefined and unprotected

> fB:=x->B(n,x)*p^x*(1-p)^(n-x);
fP:=x->mu^x/x!*exp(-mu);

>

fB := proc (x) options operator, arrow; B(n,x)*p^x*...

fP := proc (x) options operator, arrow; mu^x*exp(-m...

> mu:=2: p:=mu/n;

p := 2*1/n

> n:=10:plot([fB(x),fP(x)],x=0..n,color=[blue,pink]);

[Maple Plot]

> sum(fB(x),x=0..5);evalf(%);sum(fP(x),x=0..5);evalf(%);

9703424/9765625

.9936306176

109/15*exp(-2)

.9834363913

> n:=20:plot([fB(x),fP(x)],x=0..n,color=[blue,red]);sum(fB(x),x=0..5);evalf(%);sum(fP(x),x=0..5);evalf(%);

[Maple Plot]

24718671645887274993/25000000000000000000

.9887468658

109/15*exp(-2)

.9834363913

> n:=30:plot([fB(x),fP(x)],x=0..n,color=[blue,black]);

[Maple Plot]

> n:=60:plot(fB(x)-fP(x),x=0..10);

[Maple Plot]

4.

> restart:

Warning, the name changecoords has been redefined

> with(inttrans):alias(u=Heaviside): # alias(u=inttrans[Heaviside]):

a)

> Int(a+b*t,t=30..90): %=value(%);

Int(a+b*t,t = 30 .. 90) = 60*a+3600*b

> rhs(%)=1,a+90*b=0;

60*a+3600*b = 1, a+90*b = 0

> solve({%},{a,b});

{b = -1/1800, a = 1/20}

> f:=unapply((u(t-30)-u(t-90))*subs(%,a+b*t),t);

f := proc (t) options operator, arrow; (u(t-30)-u(t...

> plot(f,20..100);

[Maple Plot]

> Int(f(t),t=-infinity..infinity): %=value(%); # Tarkistus.

Int((u(t-30)-u(t-90))*(1/20-1/1800*t),t = -infinity...

> F:=int(f(x),x=-infinity..t);F:=collect(%,{u(t-30),u(t-90)});

F := 1/20*u(t-30)*t-5/4*u(t-30)-1/3600*u(t-30)*t^2-...

F := (-1/3600*t^2+1/20*t-5/4)*u(t-30)+(9/4+1/3600*t...

> plot(F,t=20..100,axes=box);

[Maple Plot]

> convert(F,piecewise);

PIECEWISE([0, t <= 30],[-1/3600*t^2+1/20*t-5/4, t <...

b)

> FF:=unapply(F,t);

FF := proc (t) options operator, arrow; (-1/3600*t^...

> FF(60)-FF(40);evalf(%);

4/9

.4444444444

> 1-FF(60);

1/4

c)

> mu:=int(t*f(t),t=30..90);

mu := 50

> int((t-mu)^2*f(t),t=30..90);sqrt(%);evalf(%);

200

10*sqrt(2)

14.14213562

5.

> restart: with(combinat): alias(B=binomial):

Warning, the name changecoords has been redefined

Warning, the protected name Chi has been redefined and unprotected

> f:=x->B(M,x)*B(N-M,n-x)/B(N,n);

f := proc (x) options operator, arrow; B(M,x)*B(N-M...

> N:=20: M:=5: n:=3:

> f(x);f(0),f(1),f(2),f(3);evalf(%);

1/1140*B(5,x)*B(15,3-x)

91/228, 35/76, 5/38, 1/114

.3991228070, .4605263158, .1315789474, .8771929825e...

> plot(f,0..3);plot([seq([x,f(x)],x=[$0..3])],style=point,symbol=cross,symbolsize=20,axes=box);

[Maple Plot]

[Maple Plot]

> with(plots):with(plottools):display([seq(line([x,0],[x,f(x)]),x=[$0..3])],color=blue,axes=box,linestyle=6,thickness=2);

[Maple Plot]

>

6.

> restart:

Warning, the name changecoords has been redefined

> with(plots):

> F:=x->Phi((x-mu)/sigma);

F := proc (x) options operator, arrow; Phi((x-mu)/s...

> toda:=1-F(x1);

toda := 1-Phi((x1-mu)/sigma)

> mu:=12000: sigma:=2000: x1:=15000: toda;

1-Phi(3/2)

> Phi:=x->1/2+1/2*erf(x/sqrt(2));

Phi := proc (x) options operator, arrow; 1/2+1/2*er...

> toda;evalf(%);

1/2-1/2*erf(3/4*sqrt(2))

.668072012e-1

> f:=x->1/(sigma*sqrt(2*Pi))*exp(-1/2*((x-mu)/sigma)^2);

f := proc (x) options operator, arrow; exp(-1/2*(x-...

> display(plot(f,mu-3*sigma..x1),plot(f,x1..mu+3*sigma,filled=true,color=red));

[Maple Plot]

b)

> 1-F(x)=0.02;

1/2-1/2*erf(1/2*(1/2000*x-6)*sqrt(2)) = .2e-1

> plot(lhs(%)-rhs(%),x=mu+sigma..mu+3*sigma);

[Maple Plot]

> x2:=fsolve(1-F(x)=0.02,x=16000);plot(f,x1..x2);

x2 := 16107.49782

[Maple Plot]

>

>