-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_population.m
39 lines (37 loc) · 2.12 KB
/
gen_population.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#############################################################
# Estimation of Distribution Algorithm (EDA) #
# (Octave implementation) #
# #
# Filename: gen_population.m #
# #
# Description: #
# This function generates a new population (a set of #
# solutions). In this case, we generate a set of random #
# numbers normally distributed BY VARIABLE, using the #
# mean and the standard deviation of each of those. #
# #
# Input variables #
# - mus | A row vector containing the means of #
# | each variable. Its size is (1, col_num) #
# #
# - sigmas | A row vector containing the standard #
# | deviation of each variable. Its size is #
# | (1, col_num) #
# #
# - row_num | The number of solutions of the #
# | initial population. #
# #
# - col_num | The number of elements of each #
# | solution. #
# #
# Output variables #
# - population | A random normally distributed (by #
# | variable) population. #
# #
# Author: Nico Formoso ([email protected]) #
#############################################################
function [ population ] = gen_population( mus, sigmas, row_num, col_num )
for i = 1:col_num
population(:, i) = round( normrnd(mus(i), sigmas(i), [row_num 1]) );
endfor
endfunction