如何在 Matlab 中生成一个随机数,以获得良好的散布分布?

时间:2021-07-11 23:56:06

标签: matlab random distribution scatter-plot

我想在 Matlab 中生成随机数以获得良好的分布,但是,我只有一行...

我尝试使用 random('HalfNormal',500,500)random('Binomial',50,rand(1,1));random('Logistic',0,0.1);,但我只得到了这样的结果:

The line distribution, which is bad to me

但我需要这样的东西:

enter image description here

我该怎么做?

更新: 我的数据生成器代码,用于数据的第一部分:

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

1 个答案:

答案 0 :(得分:1)

我建议您只使用随机值,即您由此生成的值。不要将其添加到现有值中,直接使用即可。

另外,我推荐均匀、二项式、半正态分布,但具有更大的值,例如: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
相关问题