-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathseismic_simulation.m
143 lines (114 loc) · 4.32 KB
/
seismic_simulation.m
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
% Adım 1: Veriyi yükleme ve hazırlama
data = readtable('Earthquake_Prediction_Analysis_Project/earthquake_data.csv');
mag = data.mag;
depth = data.depth;
date_time = datetime(data.date_time);
% Adım 2: Örnekleme frekansını hesaplama
duration_seconds = seconds(date_time(end) - date_time(1)); % Toplam süreyi saniyeye dönüştürme
L = length(mag); % Veri uzunluğu
Fs = L / duration_seconds; % Örnekleme frekansı (Hz)
% Adım 3: FFT uygulama
Y = fft(mag); % FFT uygulama
% Adım 4: Frekans spektrumunu analiz etme
P2 = abs(Y/L); % Tek yan spektrumu hesapla
P1 = P2(1:L/2+1); % Tek yan spektrumu
P1(2:end-1) = 2*P1(2:end-1); % İlk ve son elemanları hariç iki katına çıkar
f = Fs*(0:(L/2))/L; % Frekans domaini oluştur
% Adım 5: FFT Sonuçlarını Görselleştirme
figure;
subplot(2,1,1);
plot(f,P1);
title('Single-Sided Amplitude Spectrum of Magnitude Data');
xlabel('Frequency (Hz)');
ylabel('|Magnitude|');
% Adım 6: Zaman Serisi Analizi
subplot(2,1,2);
plot(date_time, mag);
title('Magnitude Data over Time');
xlabel('Time');
ylabel('Magnitude');
% Adım 7: Regresyon Analizi
figure;
scatter(depth, mag);
title('Regression Analysis: Depth vs Magnitude');
xlabel('Depth');
ylabel('Magnitude');
% Adım 8: Makine Öğrenimi Modeli (Regresyon Modeli)
X = [ones(size(depth)) depth]; % Özellik matrisi (konstant ve derinlik)
[b, bint, r, rint, stats] = regress(mag, X); % Regresyon analizi
% Modelin katsayıları
intercept = b(1);
slope = b(2);
% R-kare değeri
R_squared = stats(1);
% Hata terimlerinin standart sapması
error_std = sqrt(stats(4));
% Modeli görselleştirme
figure;
scatter(depth, mag);
hold on;
plot(depth, intercept + slope * depth, 'r', 'LineWidth', 2);
xlabel('Depth');
ylabel('Magnitude');
title('Regression Analysis: Depth vs Magnitude');
legend('Data', 'Regression Line');
% Adım 9: Diğer Analizler
% Varyans Analizi
variance_depth = var(depth);
variance_mag = var(mag);
fprintf('Depth Variance: %.4f\n', variance_depth);
fprintf('Magnitude Variance: %.4f\n', variance_mag);
% Adım 10: Zaman Serisi Analizi ve Görselleştirme
figure;
plot(date_time, mag, 'b', 'LineWidth', 1.5);
title('Magnitude Time Series', 'FontSize', 14);
xlabel('Date Time', 'FontSize', 12);
ylabel('Magnitude', 'FontSize', 12);
datetick('x', 'yyyy-mm-dd'); % Tarih zaman eksenini biçimlendirme
% Adım 11: Veri Dağılımı Analizi ve Görselleştirme
figure;
subplot(2, 1, 1);
histogram(mag, 'Normalization', 'probability', 'FaceColor', 'blue');
title('Magnitude Histogram', 'FontSize', 14);
xlabel('Magnitude', 'FontSize', 12);
ylabel('Probability', 'FontSize', 12);
subplot(2, 1, 2);
histogram(depth, 'Normalization', 'probability', 'FaceColor', 'green');
title('Depth Histogram', 'FontSize', 14);
xlabel('Depth', 'FontSize', 12);
ylabel('Probability', 'FontSize', 12);
% Adım 12: İstatistiksel Özet Bilgileri
mag_mean = mean(mag);
mag_std = std(mag);
mag_min = min(mag);
mag_max = max(mag);
depth_mean = mean(depth);
depth_std = std(depth);
depth_min = min(depth);
depth_max = max(depth);
fprintf('Magnitude Statistics:\n');
fprintf('Mean: %.2f, Standard Deviation: %.2f, Min: %.2f, Max: %.2f\n', mag_mean, mag_std, mag_min, mag_max);
fprintf('Depth Statistics:\n');
fprintf('Mean: %.2f, Standard Deviation: %.2f, Min: %.2f, Max: %.2f\n', depth_mean, depth_std, depth_min, depth_max);
% Adım 13: Kutu Grafiği ile Görselleştirme
figure;
boxplot([mag, depth], 'Labels', {'Magnitude', 'Depth'});
title('Boxplot of Magnitude and Depth', 'FontSize', 14);
ylabel('Values', 'FontSize', 12);
% Adım 14: Yoğunluk Haritası Oluşturma
figure;
scatter(date_time, depth, 20, mag, 'filled');
colormap(jet); % Renk haritasını ayarla
colorbar; % Renk skalasını ekle
datetick('x', 'yyyy-mm-dd'); % Tarih zaman eksenini biçimlendirme
title('Depth vs. Time with Magnitude Color Mapping', 'FontSize', 12);
xlabel('Date Time', 'FontSize', 12);
ylabel('Depth', 'FontSize', 12);
caxis([min(mag) max(mag)]); % Renk skalasını ayarla
% Adım 15: Deprem Büyüklüğü ve Derinlik İlişkisi Scatter Plot
figure;
scatter(mag, depth, 50, 'b', 'filled');
title('Magnitude vs. Depth Scatter Plot', 'FontSize', 14);
xlabel('Magnitude', 'FontSize', 12);
ylabel('Depth', 'FontSize', 12);
% Ekstra adımlarınızı buraya ekleyebilirsiniz.