How to randomly sample output times in Simbiology?

조회 수: 2 (최근 30일)
Wang
Wang 2024년 2월 10일
편집: Jeremy Huard 2024년 2월 15일
In the Simbiology Model Analyzer, 1) how to specify output time point of each run of the model as a random number from a normal distribution? E.g. a random number from a mean of 15min and SD 2min. 2) How to incorporate the output time as one input variable in global sensitivity analysis (Sobol index)? Thank you very much!

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2024년 2월 10일
To randomly generate values using MEAN and STD values, normrnd() fcn can be used:
MEAN_val = 15; % Mean in minutes
STD_dev = 2; % Standard deviation in minutes
Random_Number = normrnd(MEAN_val, STD_dev, 10, 1);
fprintf('Random number generated: %f \n', Random_Number);
Random number generated: 16.088707 Random number generated: 15.394483 Random number generated: 13.774981 Random number generated: 12.427133 Random number generated: 16.101281 Random number generated: 14.156724 Random number generated: 14.321607 Random number generated: 14.717372 Random number generated: 13.227484 Random number generated: 13.669566

Jeremy Huard
Jeremy Huard 2024년 2월 15일
편집: Jeremy Huard 2024년 2월 15일
Hi @Wang,
Since your ultimate goal is to run a GSA on the model output, I would recommend the following:
  1. Create parameter outTimeScalar in your model with the relevant unit
  2. Create a parameter that converts the simulation time (which can be different for every simulation program) into the same unit as the parameter outTimeScalar. This can be achieved with a repeated assignment: timeInUnitOfInterest = time
  3. Create an observable that will call an external function that you will implement in the next step, for example: out = getOutput(timeInUnitOfInterest, speciesOfinterest, outTimeScalar)
  4. Create the external function that gives you the output at this specific time:
function out = getOutput(time, speciesOfinterest, outTime)
if all(time==0)
out = speciesOfinterest(end);
else
[time,idx] = unique(time,'last');
speciesOfinterest = speciesOfinterest(idx);
outTime = outTime(1);
out = interp1(time, speciesOfinterest, outTime,'pchip');
end
end
Please note that for this to provide meaningful results, you will need to make sure that timeInUnitOfInterest(1) < outTimeScalar < timeInUnitOfInterest(end).
Now, you can use Sobol GSA or MPGSA with outTimeScalar as an input that is sampled from a normal distribution.
I hope this helps.
Best regards,
Jérémy
Edit: Corrected function.

커뮤니티

더 많은 답변 보기:  SimBiology Community

카테고리

Help CenterFile Exchange에서 Extend Modeling Environment에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by