Matlab - Ing

 
Vista:

Ing

Publicado por GermanG (1 intervención) el 20/05/2009 05:34:53
Saludos a todos.

Estoy tratando de hacer una funcion para crear mutaciones en algoritmos geneticos, que cree la mutacion con valores enteros.

El codigo que tiene matlab es para hacerlo con gaussiana y es el que pongo a continuacion... pero yo quiero es hacerlo con una distribucion uniforme, no gaussiana... Como tendria que cambiarlo?

El codigo para gaussiana es:

function mutationChildren = int_mutation(parents,options,GenomeLength, ...
FitnessFcn,state,thisScore,thisPopulation)
%Uniform (mutationuniform) — Uniform mutation is a two-step process.
%First, the algorithm selects a fraction of the vector entries of an individual for mutation,
%where each entry has a probability Rate of being mutated. The default value of Rate is 0.01.
%In the second step, the algorithm replaces each selected entry by a random number selected uniformly from the range for that entry.

shrink = .01;
scale = 0.1;
scale = scale - shrink * scale *state.Generation/options.Generations;
range = options.PopInitRange;
lower = range(1,:);
upper = range(2,:);
scale = scale * (upper - lower);
mutationPop = length(parents);
% The use of ROUND function will make sure that childrens are integers.
mutationChildren = repmat(lower,mutationPop,1) + ...
round(repmat(scale,mutationPop,1) .* rand(mutationPop,GenomeLength));
% End of mutation function

Agradezco mucho si alguien puede ayudarme a resolver esto.. gracias..

Att, German
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder