如何在 Matlab 中生成一个随机数,以获得良好的散点分布?
How to generate a random number in Matlab, to have a good scatter distribution?
我想在 Matlab 中生成随机数以获得良好的分布,但是,我只有一行...
我尝试使用 random('HalfNormal',500,500)
、random('Binomial',50,rand(1,1));
和 random('Logistic',0,0.1);
,但我只得到这样的结果:
但我需要这样的东西:
我该怎么做?
更新:
我的数据生成器代码,用于数据的第一部分:
R_i = 750;
R_0 = 7500;
t = 0.75;
a = 0.75;
for i = 1:500
R_i = R_i + random('HalfNormal',50,15);
R_0 = R_0 + random('HalfNormal',500,500);
%here is my data
[output] = ComplexChanger(R_i,R_0,t,a,random_complex_dataset);
%from here I can save to file or anything using the mean(abs(real(output))) and mean(abs(imag(output))), so I can generate a number from all of it, which means this is much more randomized
end
function [output] = ComplexChanger(R_i,R_0,t,a, random_complex_dataset)
output = R_i+(R_0-R_i)./(1+(sqrt(-1).*xdata.*t).^a); %here I change the complex data with a basic Cole stuff, which is ideal to manipulate complex number, which are good to have a two dimensional vector.
end
我建议您只使用随机值,即您由此生成的值。不要将它添加到现有值,直接使用它。
此外,我推荐均匀、二项式、半正态分布,但具有更大的值,例如:random('HalfNormal',750,50);
如果初始值为 R_i = 750;
。
因此,例如,您的最终代码可以是:
t = 0.75;
a = 0.75;
for i = 1:500
R_i = random('HalfNormal',750,50);
R_0 = random('HalfNormal',7500,500);
%here is my data
[output] = ComplexChanger(R_i,R_0,t,a,random_complex_dataset);
%from here I can save to file or anything using the mean(abs(real(output))) and mean(abs(imag(output))), so I can generate a number from all of it, which means this is much more randomized
end
function [output] = ComplexChanger(R_i,R_0,t,a, random_complex_dataset)
output = R_i+(R_0-R_i)./(1+(sqrt(-1).*xdata.*t).^a); %here I change the complex data with a basic Cole stuff, which is ideal to manipulate complex number, which are good to have a two dimensional vector.
end
我想在 Matlab 中生成随机数以获得良好的分布,但是,我只有一行...
我尝试使用 random('HalfNormal',500,500)
、random('Binomial',50,rand(1,1));
和 random('Logistic',0,0.1);
,但我只得到这样的结果:
但我需要这样的东西:
我该怎么做?
更新: 我的数据生成器代码,用于数据的第一部分:
R_i = 750;
R_0 = 7500;
t = 0.75;
a = 0.75;
for i = 1:500
R_i = R_i + random('HalfNormal',50,15);
R_0 = R_0 + random('HalfNormal',500,500);
%here is my data
[output] = ComplexChanger(R_i,R_0,t,a,random_complex_dataset);
%from here I can save to file or anything using the mean(abs(real(output))) and mean(abs(imag(output))), so I can generate a number from all of it, which means this is much more randomized
end
function [output] = ComplexChanger(R_i,R_0,t,a, random_complex_dataset)
output = R_i+(R_0-R_i)./(1+(sqrt(-1).*xdata.*t).^a); %here I change the complex data with a basic Cole stuff, which is ideal to manipulate complex number, which are good to have a two dimensional vector.
end
我建议您只使用随机值,即您由此生成的值。不要将它添加到现有值,直接使用它。
此外,我推荐均匀、二项式、半正态分布,但具有更大的值,例如:random('HalfNormal',750,50);
如果初始值为 R_i = 750;
。
因此,例如,您的最终代码可以是:
t = 0.75;
a = 0.75;
for i = 1:500
R_i = random('HalfNormal',750,50);
R_0 = random('HalfNormal',7500,500);
%here is my data
[output] = ComplexChanger(R_i,R_0,t,a,random_complex_dataset);
%from here I can save to file or anything using the mean(abs(real(output))) and mean(abs(imag(output))), so I can generate a number from all of it, which means this is much more randomized
end
function [output] = ComplexChanger(R_i,R_0,t,a, random_complex_dataset)
output = R_i+(R_0-R_i)./(1+(sqrt(-1).*xdata.*t).^a); %here I change the complex data with a basic Cole stuff, which is ideal to manipulate complex number, which are good to have a two dimensional vector.
end