Question

in phyton programming: with numpy Create a function called biochild.  The function has as parameters...

in phyton programming:
with numpy
Create a function called biochild.
 The function has as parameters the number m and the lists ??????h?? and ??????h??.

 The lists ??????h?? and ??????h?? contain 0’s and 1’s.
 For example: ??????h?? = [1,0,0,1,0,1] and ??????h?? = [1,1,1,0,0,1]
 Both lists have the same length ?.
 The 0's and 1's represent bits of information (remember that a bit is 0 or 1).

 The function has to generate a new list (child).  The child list must have the same length ?.
 child is generated by randomly combining part of the child's information ??????h?? and ??????h??.
 The first part of the child list will be made up of the first ? bits of ??????h?? and the second part by the last ? - ? bits of the ??????h??.
 For example, if ? = 3, ??????h?? = [?, ?, ?, 1,0,1] and ??????h?? = [1,1,1, ?, ?, ?], then ?h??? = [1,0,0,0,0,1].
 The value ? has to be chosen randomly by the function.

 After generating child, each bit in the list is considered for mutation.
 For each bit of child, with probability ? the bit is “mutated” by being replaced by its inverse (If the bit is 0 it is replaced by 1, and if it is 1 it is replaced by 0).
 Finally, the function returns the list child.

Homework Answers

Answer #1

Explanation :-

# First I am generating b as random number from 1 to len of biomother - 1

# Next I have initialized child_list to insert first b bits from biomother

# And then n - b bits from biofather starting from b index

# Finally after forming the child_list , I am making a final_list which has inversed bits of child_list

# Lastly returning the final_list formed.

#Function  

def biochild(m,biomother,biofather):
import random
child_list = []
len_biomother = len(biomother)
b = random.randint(1,len_biomother-1)
  
for i in range(b):
child_list.append(biomother[i])
  
for i in range(b,len(biofather)):
child_list.append(biofather[i])
  
final_list = []
for i in child_list:
if i == 0:
final_list.append(1)
else:
final_list.append(0)
return final_list

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...
Program has to be written in ML language. Write functions in ML to do the following:...
Program has to be written in ML language. Write functions in ML to do the following: 1. Given a list, return that list with its first and third elements deleted. Assume the length of the list is at least 3. 2. Given a list of real pairs, return the list containing the larger element in each pair. Examples: larger_in_pair([]) = [] larger_in_pair([(1.0,2.5),(4.7,3.6),(5.5,8.8)] = [2.5,4.7,8.8] 3. Given two lists of integers, return the list of the sums of the elements in...
I=interval with rl #'s which has x=0. f(x) is an odd function that is differentiable on...
I=interval with rl #'s which has x=0. f(x) is an odd function that is differentiable on I. show that f(0)=0 and f'(x) is even. for part 2, f(x) is an even function with the same characteristics as part 1. show f'(x) is odd. please show all the work for a thumbs up.
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n ==...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n == 0)    return 0; else    return n * f(n - 1); } A. 120 B. 60 C. 1 D. 0 10 points    QUESTION 2 Which of the following statements could describe the general (recursive) case of a recursive algorithm? In the following recursive function, which line(s) represent the general (recursive) case? void PrintIt(int n ) // line 1 { // line 2...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational numbers in a mixed number format (integer part and a fraction part). Details and Requirements Your class must allow for storage of rational numbers in a mixed number format. Remember that a mixed number consists of an integer part and a fraction part (like 3 1/2 – “three and one-half”). The Mixed class must allow for both positive and negative mixed number values. A...
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question....
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question. Thank you! Here’s the contents of a file called example.cpp: // example.cpp #include "LinkedList.h" #include <iostream> #include <string> using namespace std; int main() { cout << "Please enter some words (ctrl-d to stop):\n"; LinkedList lst; int count = 0; string s; while (cin >> s) { count++; lst.add(remove_non_letters(s)); } // while cout << "\n" << count << " total words read in\n"; cout <<...
Use Matlab to solve the following (a) Create a plot with a sphere at the center...
Use Matlab to solve the following (a) Create a plot with a sphere at the center of the graph (origin) representing the sun with a radius of 6955000 km. Make sure that the outside of the sphere is painted in ’autumn’ colors. (Hint: look up the sphere() function, the colormap() function, and the surf() function). (b) Create a variable t ranging from 0 to 2? with increments of 0.01. (c) The following Table gives you important values needed to compute...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
do all five questions Question 1 20 pts Ignoring the effects of air resistance, if a...
do all five questions Question 1 20 pts Ignoring the effects of air resistance, if a ball falls freely toward the ground, its total mechanical energy Group of answer choices increases remains the same not enough information decreases Flag this Question Question 2 20 pts A child jumps off a wall from an initial height of 16.4 m and lands on a trampoline. Before the child springs back up into the air the trampoline compresses 1.8 meters. The spring constant...
2.         Earlier this semester we had a problem with birds with sore throats. I own the...
2.         Earlier this semester we had a problem with birds with sore throats. I own the pet store that has these birds and I need to get them some medical treatment. When I look in the phone book, I find four veterinarian hospitals/clinics with doctors that treat birds. They are:                   a.         Animal Lover’s Animal Hospital (A L A H) b.   Victor’s Vetnarian Clinic (V2 C) c.   The Home for Wobbly Wings (H W2);   and d.   Rudolph’s Tiny Animal Shelter...