MATLAB Answers

how can use randn function with any matrix and negative or not integers numbers ??

2 views (last 30 days)
qusai baniamer
qusai baniamer on 16 Sep 2021
Answered: Star Strider on 16 Sep 2021
if we have matrix X with size (1*10) for example, how can achieved new matrix (Y for example) with using gaussian equation?
x= [ 1.542 -2.551 0.657 6.337 -0.678 3.758 8.421 -4.215 0.854 -0.924 ]

Answers (1)

Star Strider
Star Strider on 16 Sep 2021
I am not certain what the desired result is.
One possibility —
x = [ 1.542 -2.551 0.657 6.337 -0.678 3.758 8.421 -4.215 0.854 -0.924 ];
df = fitdist(x(:), 'Normal')
df =
NormalDistribution Normal distribution mu = 1.3201 [-1.46982, 4.11002] sigma = 3.90004 [2.68258, 7.11995]
xv = linspace(min(x), max(x));
Probabilities = [x; normpdf(x,df.mu,df.sigma)]
Probabilities = 2×10
1.5420 -2.5510 0.6570 6.3370 -0.6780 3.7580 8.4210 -4.2150 0.8540 -0.9240 0.1021 0.0625 0.1008 0.0447 0.0897 0.0841 0.0195 0.0374 0.1016 0.0867
figure
plot(xv, normpdf(xv,df.mu, df.sigma))
hold on
plot([x;x], [0;1]*normpdf(x,df.mu,df.sigma), '--k')
hold off
grid
legend('Normal Distribution','Mapped x-Values', 'location','best')
Make appropriate changes to get the desired result.
.

Community Treasure Hunt

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

Start Hunting!