Математическая статистика и случайные процессы

реклама
Балтийский государственный технический университет
«Военмех» им. Д.Ф. Устинова
Кафедра И7
«Кафедра математической статистики и прикладной математики»
«Математическая статистика и случайные процессы»
Случайные процессы
Лабораторная работа № 6
«Моделирование случайных процессов методом отбора в пакете Matlab»
Вариант 6
Выполнил:
Студент Козятинский Н.В.
Группа И383
Преподаватель:
Гнидин В.В.
Санкт-Петербург
2011
𝑓(𝑥, 𝑦) = 𝑐𝑜𝑠𝑥 × 𝑐𝑜𝑠𝑦
0 0
(𝜋 𝜋)
2 2
Dens.m
function f1 = dens(x)
f1 = cos(x(1))*cos(x(2));
setkamax.m
function f2 = setkamax(A, B, h, n)
% A и B - матрицы с предельными значениями аргумента
% h - шаг сетки, n - размерность исходной функции
for i = 1:n
a = B(i)-A(i);
nn(i) = a/h;
end
for i1 = 1:nn(1)
for i2 = 1:nn(2)
x0(1) = A(1) + (i1-1)*h;
x0(2) = A(2) + (i2-1)*h;
xx(i1,i2) = dens(x0);
end
end
fmax = 1e-9;
for i1 = 1:nn(1)
for i2 = 1:nn(2)
if fmax<xx(i1,i2)
fmax = xx(i1,i2);
end
end
end
f2 = fmax;
metodotbora.m
function [kk,Z] = metodotbora(n,L,m,A,B,fmax)
for i = 1:n
a(i) = abs(B(i) + A(i));
end
KSI = zeros(n,21);
ZZ = zeros(21,10);
ab = zeros(L);
for nm = 1:L
for i = 1:m
x1(i) = fmax*rand;
for j = 1:n
x(j,i) = a(j)*rand - A(j);
end
end
k = 0;
for i = 1:m
for k1 = 1:n
xh(k1) = x(k1,i);
end
z(i) = abs(dens(xh));
if x1(i)<=z(i)
k=k+1;
ab(nm) = k;
for j = 1:n
KSI(j,k) = x(j,i);
end
end
if k>21
break
end
end
for i = 1:k
b=0;
for j=1:n
b=b+abs(KSI(j,i))^2;
end
ZZ(i,nm) = sqrt(b);
end
end
kk=ab;
Z=ZZ;
Petchgraf.m
function f3 = petchgraf(kk1,z1)
syms s1 s2 s3 s4 s5 s6 s7 s8 s9 s10
s1 = 'y';
s2 = 'm';
s3 = 'c';
s4 = 'r';
s5 = 'g';
s6 = 'b';
s7 = 'k';
s8 = '-.k';
s9 = ':r';
s10 = ':g';
for i=1:21
t(i) = i;
end
for i=1:21
KSI1(i) = z1(i,1);
KSI2(i) = z1(i,2);
KSI3(i) = z1(i,3);
KSI4(i) = z1(i,4);
KSI5(i) = z1(i,5);
KSI6(i) = z1(i,6);
KSI7(i) = z1(i,7);
KSI8(i) = z1(i,8);
KSI9(i) = z1(i,9);
KSI10(i) = z1(i,10);
end
plot(t,KSI1,s1),hold on
plot(t,KSI2,s2),hold on
plot(t,KSI3,s3),hold on
plot(t,KSI4,s4),hold on
plot(t,KSI5,s5),hold on
plot(t,KSI6,s6),hold on
plot(t,KSI7,s7),hold on
plot(t,KSI8,s8),hold on
plot(t,KSI9,s9),hold on
plot(t,KSI10,s10),hold on
f3 = kk1;
main.m
n
L
m
A
B
h
=
=
=
=
=
=
2;
10;
10000;
[0 0];
[pi/2 pi/2];
1;
fmax = setkamax(A,B,h,n)
[c,z] = metodotbora(n,L,m,A,B,fmax);
c
z
c1 = petchgraf(c,z)
Результат
fmax =
0.6366
c =
22
0
0
22
0
0
22
0
0
22
0
0
22
0
0
22
0
0
22
0
0
22
0
0
22
0
0
22
0
0
z =
Columns 1 through 6
0.8503
0.4247
1.2533
0.5126
0.4772
0.7538
0.2468
0.3585
1.1244
1.4132
0.5552
1.2845
0.7532
1.1324
0.8021
2.1154
0.7641
0.7418
1.1854
0.3645
0.6903
0.9257
1.0314
0.2992
0.8120
0.7727
0.3852
0.7397
0.8507
0.5337
1.2915
0.0883
0.7663
0.8539
0.6373
0.7282
0.7228
1.4517
0.4131
0.4474
0.6747
0.7940
0.3866
1.6607
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.7553
0.2872
0.5225
0.5192
0.3843
0.2619
0.6765
1.2884
0.6374
0.5239
1.0043
0.2339
0.3687
0.7098
0.1352
0.2269
1.5283
1.5587
0.3462
0.9916
1.0417
0.7636
0.3447
0.3882
1.1418
0.3654
0.0526
0.6296
0.7023
0.2144
0.2594
0.7951
1.5026
1.4758
1.0845
0.1760
0.1124
0.2480
1.2816
0.9812
1.1142
0.1555
1.2007
0.7585
0.7865
0.7518
0.2056
0.9333
0.2885
0.1913
0.2874
0.7474
1.2505
0.5474
0.7082
1.2539
0.3287
0.4092
Columns 7 through 10
0.7163
0.1986
0.9460
1.2081
0.2383
0.6854
1.0479
0.5537
0.2876
0.2762
0.7797
0.6924
1.0703
0.6077
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.6305
0.0674
0.8931
0.0925
0.1820
0.1326
0.6944
0.8623
1.4207
0.8961
0.7245
1.2378
0.5221
1.3367
1.0266
0.8216
0.3523
1.4162
0.5500
0.5671
0.7045
0.5449
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.8347
0.0966
1.1499
0.3214
0.6976
0.2216
0.6170
0.5046
0.0633
0.6952
0.2945
0.8801
0.9024
1.3122
0.7041
0.5651
0.6308
0.3802
0.3979
0.3426
0.6792
0.9248
0.4579
0.6074
0.6487
0.5171
1.6812
0.8321
0.8122
0.5269
0.3802
0.6532
0.2939
0.5845
0.3361
0.6644
0.3173
c1 =
22
22
22
22
22
22
22
22
22
22
1.4969
0.4747
1.2967
0.3274
0.4023
0.5126
0.4430
1.2242
0.3425
0.5903
1.2649
0.1322
0.2206
1.2787
0.6419
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.6008
0.7087
0.2836
0.2789
0.8841
0.5744
0.4609
0.2785
1.2188
0.6237
0.4583
1.5465
0.6058
0.2021
0.2517
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.7403
0.1499
0.6518
0.3543
1.2547
0.1461
0.4958
0.4628
0.2009
1.5119
0.9402
0.3495
1.3031
1.2794
0.9784
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Скачать