Whenever I create a normrnd like the one expressed below,Gaussian = normrnd([1 45],[1 45],[1 500],length(c_t));我遇到以下错误,Size information is inconsistent.创建此PDF的原因是为了计算具有可变高斯噪声模型的示踪剂的化学动力学.基本上,我具有示踪剂的理想特性,现在我想添加高斯噪声,并了解示踪剂的化学动力学如何随噪声的变化而变化.The reason for creating this PDF is to compute Chemical kinetics of a tracer with variable gaussian noise model. Basically i have an Ideal characteristics of a Tracer now i would like to add gaussian noise and understand how the chemical kinetics of a tracer vary with changing noise.基本上有不同的计算模型可以理解示踪剂的化学动力学,其中一种是三室模型,另一种是形状分析,约束形状分析模型.Basically there are different computational models for understanding chemical kinetics of tracer, one of which is Three compartmental model ,others are viz shape analysis,constrained shape analysis model.我目前对所有模型都有理想的曲线,现在我想给这些模型添加噪声,并了解每个特定模型在变化的噪声下的行为I currently have ideal curve for all respective models, now i would like to add noise to these models and understand how each particular model behaves with varying noise这就是为什么我想使用 normrnd 将此模型添加到理想特性中,并计算噪声(Sigma)与误差(Vs Error)-此分析将为我提供一个近似的估计,即不同模型在变化的噪声下的行为方式以及适合于估算示踪剂化学动力学的模型.This is why i would like to create a variable noise model with normrnd add this model to ideal characteristics and compute Noise(Sigma) Vs Error -This analysis will give me an approximate estimation how different models behave with varying noise and which model is suitable for estimating chemical kinetics of tracer.function [c_t,c_t_noise] =Noise_ConstrainedK2(t,a1,a2,a3,b1,b2,b3,td,tmax,k1,k2,k3) K_1 = (k1*k2)/(k2+k3); K_2 = (k1*k3)/(k2+k3); %DV_free= k1/(k2+k3); c_t = zeros(size(t)); ind = (t > td) & (t < tmax); c_t(ind)= conv(((t(ind) - td) ./ (tmax - td) * (a1 + a2 + a3)),(K_1*exp(-(k2+k3)*t(ind)+K_2)),'same'); ind = (t >= tmax); c_t(ind)=conv((a1 * exp(-b1 * (t(ind) - tmax))+ a2 * exp(-b2 * (t(ind) - tmax))) + a3 * exp(-b3 * (t(ind) - tmax)),(K_1*exp(-(k2+k3)*t(ind)+K_2)),'same'); meanAndVar = (rand(45,2)-0.5)*2; numPoints = 500; randSamples = zeros(1,numPoints); for ii = 1:numPoints idx = mod(ii,size(meanAndVar,1))+1; randSamples(ii) = normrnd(meanAndVar(idx,1),meanAndVar(idx,2)); c_t_noise = c_t + randSamples(ii); end scatter(1:numPoints,randSamples) dg = [0 0.5 0]; plot(t,c_t,'r'); hold on; plot(t,c_t_noise,'Color',dg); hold off; axis([0 50 0 1900]); xlabel('Time[mins]'); ylabel('concentration [Mbq]'); title('My signal'); %plot(t,c_tnp);end上述功能的输出特性如下,这里我看不到任何噪声The output characteristics from the above function are as follows,Here i could not visualize any noise推荐答案可以通过以下方法完成唯一接近您要完成的操作,但是会涉及到循环,因为您不能仅从45个请求500个数据点不同的均值和方差,而无需假设可以重新访问多个集合.The only remotely close thing to what you want to be done can be done as follows, but will involve looping because you can not request 500 data points from only 45 different means and variances, without the assumption that multiple sets can be revisited.这是我对您想要的内容的解释,尽管我仍然不确定.This is my interpretation of what you want, though I am still not entirely sure. 随机高斯函数选择meanAndVar = rand(45,2);numPoints = 500;randSamples = zeros(1,numPoints);for ii = 1:numPoints randMeanVarIdx = randi([1,size(meanAndVar,1)]); randSamples(ii) = normrnd(meanAndVar(randMeanVarIdx,1),meanAndVar(randMeanVarIdx,2));endscatter(1:numPoints,randSamples)上面的代码生成均值和方差的随机二维矩阵(第一个col =均值,第二个col =方差).然后,我们预分配一些空间.The above code generates a random 2-D matrix of mean and variance (1st col = mean, 2nd col = variance). We then preallocate some space.在循环内部,我们选择了一组均值和方差随机使用(均匀),然后取该均值和方差,将其插入随机高斯值函数中并进行存储.Inside the loop we chose a random set of mean and variance to use (uniformly) and then take that mean and variance, plug it into a random gaussian value function, and store it.矩阵randSamples将包含一列随机值,这些值是由以随机均匀方式选择的一组随机的高斯函数生成的.the matrix randSamples will contain a list of random values generated by a random set of gaussian functions chosen in a randomly uniform manner. 顺序功能选择如果您不想随机选择要使用的函数,而只想顺序执行,则可以使用模数循环获取要使用的一组值的索引.If you do not want to randomly select which function to use, and just want to go sequentially you loop using modulus to get the index of which set of values to use.meanAndVar = (rand(45,2)-0.5)*2; % zero shift and make bounds [-1,1]numPoints = 500;randSamples = zeros(1,numPoints);for ii = 1:numPoints idx = mod(ii,size(meanAndVar,1))+1; randSamples(ii) = normrnd(meanAndVar(idx,1),meanAndVar(idx,2));endscatter(1:numPoints,randSamples) 这篇关于高斯随机函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-07 02:19