Update PT curve code

This commit is contained in:
Ksyer
2024-07-22 20:30:10 +08:00
parent ec9c2ca952
commit bd1aff0ee0
3 changed files with 78 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
function I = get_integral(cache_filename, var_name, tau_range, M)
syms x f;
if exist(cache_filename, "file")
data = load(cache_filename, var_name);
I = data.(var_name);
else
I = zeros(length(tau_range), 0);
for tau_idx = 1:length(tau_range)
tau = tau_range(tau_idx);
f = (x - tau) ^ 2 * exp(-x ^ 2/2) * x ^ (M - 1) / (2 ^ (M / 2 - 1) * gamma(M / 2));
I(tau_idx) = double(int(f, [tau, +inf]));
end
S.(var_name) = I;
save(cache_filename, '-struct', 'S', var_name);
end
end