Update weighted_sample_with_replacement() in utils.py (#366) · TonyJava/aima-python@bddd1cf · GitHub
Skip to content

Commit bddd1cf

Browse files
sofmonknorvig
authored andcommitted
Update weighted_sample_with_replacement() in utils.py (aimacode#366)
* Update utils.py in pseudo code the sequence of arguments is " WEIGHTED-SAMPLE-WITH-REPLACEMENT(N, S, W)"  same must follow in function "particle_filtering" in the file probability.py * Update learning.py weight_sample_with_replacement sequence of args * Update probability.py weighted_sample_with_replacement sequence of args * Update search.py
1 parent 14bf5e4 commit bddd1cf

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

learning.py

Lines changed: 1 addition & 1 deletion

probability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,5 +651,5 @@ def particle_filtering(e, N, HMM):
651651
w[i] = float("{0:.4f}".format(w[i]))
652652

653653
# STEP 2
654-
s = weighted_sample_with_replacement(s, w, N)
654+
s = weighted_sample_with_replacement(N,s,w)
655655
return s

search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ def genetic_algorithm(population, fitness_fn, ngen=1000, pmut=0.1):
587587
new_population = []
588588
for i in range(len(population)):
589589
fitnesses = map(fitness_fn, population)
590-
p1, p2 = weighted_sample_with_replacement(population, fitnesses, 2)
590+
p1, p2 = weighted_sample_with_replacement(2,population, fitnesses)
591591
child = p1.mate(p2)
592592
if random.uniform(0, 1) < pmut:
593593
child.mutate()

utils.py

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)