How do I add summation to a symbolic equation in order to integrate across set bounds?
The goal is to integrate from a set number to infinity (or some larger number) for function GF-PDF, which is a lognormal distribution with a geometric mean GF (GFg) and spread (sigma). Each GF-PDF is specifically collected for/interpolated to a dry size (Dp) and the other distribution parameters (GFg, sigma) are fit to the data through a data inversion algorithm. For one mode in the distribution, the equation is:
The issue is that sometime there are multiple modes within one GF-PDF and so the equation becomes:
…where for each mode (k), there is a number fraction (f0,k), geometric mean GF (GFg,k), and spread (sigmak) that described each mode and the sum of all the modes is the distribution. The f0, GFg, and sigma are different for all the modes making up the GF-PDF.
The integration I’m trying to do is:
…where I can integrate above a specific value for GFc (that was calculated for a chosen Sc at a chosen Dp) and get the area/fraction of particles above that GFc since the GF-PDF is at unity. I know how to use trapz(), but integration as a whole has been confusing me. From what I have been reading, I need to input the GF-PDF as a symbolic function, but I’m uncertain on how to add the summation to the symbolic equation in the cases where 2 or more modes are present. I could create the single mode equation as a symbolic function, but I’m again not sure how to integrate across the summation of the equations.
Below are functions I created to create the GF-PDFs, but I know that they aren’t symbolic. I add some sample parameters and the range of GF too.
binsp = (exp(1/60)*0.7)-0.7; % logspace for GF range
gf_rng = 0.90:binsp:2.5; % range of GF in log-space for the GF-PDFs
% Example values for a bimodal (k = 2) GF-PDF:
g0s = [1.1,1.5]; % geometric mean GF
sig0s = [1.04,1.05]; % spread in GF
f0s = [0.4,0.6]; % number fraction of mode
% GF-PDF for GF range
gfpdf = GFPDFf(gf_rng,g0s,sig0s,f0s); % uses functions at bottom
% I could make a symbolic function for just the one lognormal mode, I’m not
% sure how to sum them both in it though…
gf_rng = sym(‘gf_rng’);
g0s = sym(‘g0s’);
sig0s = sym(‘sig0s’);
f0s = sym(‘f0s’);
GFPDF_1m = (f0s./sqrt(2.*pi.*(log(sig0s)).^2)).*exp((-0.5).*((log(gf_rng./g0s).^2)./((log(sig0s)).^2)))
% I’m uncertain where to go from here if I want to integrate from GFc to
% infinity for the bimodal curve…
GFc = 1.3; % random GFc value
% Functions for GF-PDF creations
% Calculating the GFPDF:
function npdf = GFPDFf(gf_rng,g0s,sig0s,f0s)
if width(g0s)>1
for i = 1:width(g0s)
pdf(i,:) = lnPDF(gf_rng,g0s(1,i),sig0s(1,i),f0s(1,i));
end
npdf = sum(pdf);
else
npdf = lnPDF(gf_rng,g0s,sig0s,f0s);
end
end
% Plotting Lognormal Modes:
function pdf = lnPDF(gf_rng,g0s,sig0s,f0s)
pdf = (f0s./sqrt(2.*pi.*(log(sig0s)).^2)).*exp((-0.5).*((log(gf_rng./g0s).^2)./((log(sig0s)).^2)));
endThe goal is to integrate from a set number to infinity (or some larger number) for function GF-PDF, which is a lognormal distribution with a geometric mean GF (GFg) and spread (sigma). Each GF-PDF is specifically collected for/interpolated to a dry size (Dp) and the other distribution parameters (GFg, sigma) are fit to the data through a data inversion algorithm. For one mode in the distribution, the equation is:
The issue is that sometime there are multiple modes within one GF-PDF and so the equation becomes:
…where for each mode (k), there is a number fraction (f0,k), geometric mean GF (GFg,k), and spread (sigmak) that described each mode and the sum of all the modes is the distribution. The f0, GFg, and sigma are different for all the modes making up the GF-PDF.
The integration I’m trying to do is:
…where I can integrate above a specific value for GFc (that was calculated for a chosen Sc at a chosen Dp) and get the area/fraction of particles above that GFc since the GF-PDF is at unity. I know how to use trapz(), but integration as a whole has been confusing me. From what I have been reading, I need to input the GF-PDF as a symbolic function, but I’m uncertain on how to add the summation to the symbolic equation in the cases where 2 or more modes are present. I could create the single mode equation as a symbolic function, but I’m again not sure how to integrate across the summation of the equations.
Below are functions I created to create the GF-PDFs, but I know that they aren’t symbolic. I add some sample parameters and the range of GF too.
binsp = (exp(1/60)*0.7)-0.7; % logspace for GF range
gf_rng = 0.90:binsp:2.5; % range of GF in log-space for the GF-PDFs
% Example values for a bimodal (k = 2) GF-PDF:
g0s = [1.1,1.5]; % geometric mean GF
sig0s = [1.04,1.05]; % spread in GF
f0s = [0.4,0.6]; % number fraction of mode
% GF-PDF for GF range
gfpdf = GFPDFf(gf_rng,g0s,sig0s,f0s); % uses functions at bottom
% I could make a symbolic function for just the one lognormal mode, I’m not
% sure how to sum them both in it though…
gf_rng = sym(‘gf_rng’);
g0s = sym(‘g0s’);
sig0s = sym(‘sig0s’);
f0s = sym(‘f0s’);
GFPDF_1m = (f0s./sqrt(2.*pi.*(log(sig0s)).^2)).*exp((-0.5).*((log(gf_rng./g0s).^2)./((log(sig0s)).^2)))
% I’m uncertain where to go from here if I want to integrate from GFc to
% infinity for the bimodal curve…
GFc = 1.3; % random GFc value
% Functions for GF-PDF creations
% Calculating the GFPDF:
function npdf = GFPDFf(gf_rng,g0s,sig0s,f0s)
if width(g0s)>1
for i = 1:width(g0s)
pdf(i,:) = lnPDF(gf_rng,g0s(1,i),sig0s(1,i),f0s(1,i));
end
npdf = sum(pdf);
else
npdf = lnPDF(gf_rng,g0s,sig0s,f0s);
end
end
% Plotting Lognormal Modes:
function pdf = lnPDF(gf_rng,g0s,sig0s,f0s)
pdf = (f0s./sqrt(2.*pi.*(log(sig0s)).^2)).*exp((-0.5).*((log(gf_rng./g0s).^2)./((log(sig0s)).^2)));
end The goal is to integrate from a set number to infinity (or some larger number) for function GF-PDF, which is a lognormal distribution with a geometric mean GF (GFg) and spread (sigma). Each GF-PDF is specifically collected for/interpolated to a dry size (Dp) and the other distribution parameters (GFg, sigma) are fit to the data through a data inversion algorithm. For one mode in the distribution, the equation is:
The issue is that sometime there are multiple modes within one GF-PDF and so the equation becomes:
…where for each mode (k), there is a number fraction (f0,k), geometric mean GF (GFg,k), and spread (sigmak) that described each mode and the sum of all the modes is the distribution. The f0, GFg, and sigma are different for all the modes making up the GF-PDF.
The integration I’m trying to do is:
…where I can integrate above a specific value for GFc (that was calculated for a chosen Sc at a chosen Dp) and get the area/fraction of particles above that GFc since the GF-PDF is at unity. I know how to use trapz(), but integration as a whole has been confusing me. From what I have been reading, I need to input the GF-PDF as a symbolic function, but I’m uncertain on how to add the summation to the symbolic equation in the cases where 2 or more modes are present. I could create the single mode equation as a symbolic function, but I’m again not sure how to integrate across the summation of the equations.
Below are functions I created to create the GF-PDFs, but I know that they aren’t symbolic. I add some sample parameters and the range of GF too.
binsp = (exp(1/60)*0.7)-0.7; % logspace for GF range
gf_rng = 0.90:binsp:2.5; % range of GF in log-space for the GF-PDFs
% Example values for a bimodal (k = 2) GF-PDF:
g0s = [1.1,1.5]; % geometric mean GF
sig0s = [1.04,1.05]; % spread in GF
f0s = [0.4,0.6]; % number fraction of mode
% GF-PDF for GF range
gfpdf = GFPDFf(gf_rng,g0s,sig0s,f0s); % uses functions at bottom
% I could make a symbolic function for just the one lognormal mode, I’m not
% sure how to sum them both in it though…
gf_rng = sym(‘gf_rng’);
g0s = sym(‘g0s’);
sig0s = sym(‘sig0s’);
f0s = sym(‘f0s’);
GFPDF_1m = (f0s./sqrt(2.*pi.*(log(sig0s)).^2)).*exp((-0.5).*((log(gf_rng./g0s).^2)./((log(sig0s)).^2)))
% I’m uncertain where to go from here if I want to integrate from GFc to
% infinity for the bimodal curve…
GFc = 1.3; % random GFc value
% Functions for GF-PDF creations
% Calculating the GFPDF:
function npdf = GFPDFf(gf_rng,g0s,sig0s,f0s)
if width(g0s)>1
for i = 1:width(g0s)
pdf(i,:) = lnPDF(gf_rng,g0s(1,i),sig0s(1,i),f0s(1,i));
end
npdf = sum(pdf);
else
npdf = lnPDF(gf_rng,g0s,sig0s,f0s);
end
end
% Plotting Lognormal Modes:
function pdf = lnPDF(gf_rng,g0s,sig0s,f0s)
pdf = (f0s./sqrt(2.*pi.*(log(sig0s)).^2)).*exp((-0.5).*((log(gf_rng./g0s).^2)./((log(sig0s)).^2)));
end sum, integration, symbolic, pdf MATLAB Answers — New Questions









