Random Number generation with Total sum.
Mostrar comentarios más antiguos
clear all ; clc Demand=300; N=10; D=3;
a(1:N,1)=100; b(1:N,1)=600; %bounds on variable 1
a(1:N,2)=100; b(1:N,2)=400; %bounds on variable 2
a(1:N,3)=50; b(1:N,3)=200; %bounds on variable 3
x=a+(b-a).*rand(N,D);
I want to generate random numbers whose sum is equal to Demand=300 and their bounds are specified. When I generate by this code their sum is not equal to Demand, Please tell me what to do ?
Note-> I have studied randfixedsum function in Matlab help but it doesn't help me.
2 comentarios
Sean de Wolski
el 23 de Dic. de 2014
Please don't start new questions for the same thing as an existing one.
Instead, answer my question that I posed to you:
WHY DOESN'T RANDFIXEDSUM HELP YOU?
John D'Errico
el 28 de Dic. de 2014
Editada: John D'Errico
el 28 de Dic. de 2014
Sean - randfixedsum assumes the points lie in a hyper-cube, not a hyper-rectangle. The question here has lower and upper limits that differ for each variable. The randfixedsum code assumes scalar a and b.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

