1.In this problem and the next one, we’re going to make a very simple spam checker program by just looking
...
ooking at how likely a given email is to be spam based on the words it contains. In particular, in this problem we’re going to count how often words are present in spam emails within some set of training data (which here means a set of emails that have already been marked as spam or not spam manually).
We have already started to write a function spam_score(spam_file, not_file, word), which takes in two filenames, along with a target word (a lowercase string). Both filenames refer to text files which must be in the same directory as hw07.py (we’ve provided several such files in hw07files.zip). The text files contain one email per line (really just the subject line to keep things simple) - you can assume that these emails will be a series of words separated by spaces with no punctuation. The first file contains emails that have been identified as spam, the second contains emails that have been identified as not spam.
Since you haven’t learned File I/O yet, we’ve provided code that opens the two files and puts the data into two lists of strings (where each element is one line - that is, one email). You then must complete the function, so that it returns the spam score for the target word. The spam score is an integer representing the total number of times the target word occurs across all the spam emails, minus the total number of times the word occurs in not-spam emails. Convert all words to lowercase before counting, to ensure capitalization does not throw off the count.
View More
2.Describe the parallels between cell differentiation, nutrient supply, and final cellular state for the majority of cells involved in the
...
he majority of cells involved in the epidermis, hair follicles/hair growth, and nail synthesis/nail growth.
How does the structure of spongy bone support the function of the red bone marrow contained within said bone?
How do bones, synovial fluid, tendons, ligaments, and articular cartilage work together to allow synovial joint movement? Please explicitly include the bone feature that allows for tendon/ligament attachment.
What is the difference in function between the vertebrae and the intervertebral disks in the vertebral column? Please discuss both the connective tissue subtype for each of these features and how the composition of their extracellular matrix contributes to function
Describe the extracellular matrix of bone to someone who isn't familiar with anatomy (this should be a general description of appearance/tactile nature, no specific mention of cells or function is needed)
How does hair contribute to the sensory role of the integumentary system? (A short explanation is all that is needed, no in-depth description of associated structures is required for full credit)
Back when he was 16, Jordan left eye orbit floor was fractured in a bizarre fencing accident, leaving a few fragments behind inside his skull. Assuming the floor was punctured from above in the maxillary bone and no additional bones were broken, where did the bone fragments end up in his skull? (This should be a particular space in the skull, not a separate bone where the fragments are embedded
The skeletal and integumentary systems rely heavily on collagen for function - describe one or more features other than ligaments that involve collagen, and how you would expect function to change in someone with EDS that affected the relevant subtype of collagen
View More
3.Question 1: What is a player’s « reaction function » in a Bertrand game ?
Question 2: What is a subgame
...
subgame perfect Nash equilibrium?
Question 3: In which situations should we need the mixed extension of a game?
Question 4: Find, if any, all Nash equilibria of the following famous matrix game:
L R
U (2,0) (3,3)
D (3,4) (1,2)
Question 5: What is the difference between a separating equilibrium and a pooling equilibrium
in Bayesian games?
Question 6: Give another name for, if it exists, the intersection of the players’ best-response
« functions » in a game?
Question 7: assuming we only deal with pure strategies, the Prisoner’s Dilemma is a situation
with:
No Nash equilibrium One sub-optimal Nash equilibrium
One sub-optimal dominant profile No dominant profile
Question 8: If it exists, a pure Nash equilibrium is always a profile of dominant strategies:
True False
Question 9: All games have at least one pure strategy Nash equilibrium:
True False
Question 10: If a tree game has a backward induction equilibrium then it must also be a Nash
equilibrium of all of its subgames:
Tr
2/2
Question 11: The mixed Nash equilibrium payoffs are always strictly smaller than the pure
Nash equilibrium payoffs:
True False
Question 12: Which of the following statements about dominant/dominated strategies is/are
true?
I. A dominant strategy dominates a dominated strategy in 2x2 games.
II. A dominated strategy must be dominated by a dominant strategy in all games.
III. A profile of dominant strategies must be a pure strategy Nash equilibrium.
IV. A dominated strategy must be dominated by a dominant strategy in 2x2 games.
I, II and IV only I, II and III only II and III only
I and IV only I, III and IV only I and II only
Question 13: A pure strategy Nash equilibrium is a special case of a mixed strategy Nash
equilibrium:
True False
Question 14: Consider the following 2x2 matrix game:
L R
U (3,2) (2,4)
D (-1,4) (4,3)
The number of pure and mixed Nash equilibria in the above game is:
0 1
2 3
Exercise (corresponding to questions 15 to 20 below): assume a medical doctor (M)
prescribes either drug A or drug B to a patient (P), who complies (C) or not (NC) with each of
this treatment. In case of compliance, controlled by an authority in charge of health services
quality, the physician is rewarded at a level of 1 for drug A and 2 for drug B. In case of noncompliance, the physician is « punished » at -1 level for non-compliance of the patient with
drug A and at -2 level for non-compliance with drug B. As for the compliant patient, drug A
should give him back 2 years of life saved and drug B, only 1 year of life saved. When noncompliant with drug A, the same patient wins 3 years of life (due to avoiding unexpected
allergic shock for instance), and when non-compliant with drug B, the patient loses 3 years of
life.
Question 15: You will draw the corresponding matrix of the simultaneous doctor-patient game.
Question 16: Find, if any, the profile(s) of dominant strategies of this game.
Question 17: Find, if any, the pure strategy Nash equilibrium/equilibria of this game.
Question 18: Find, if any, the mixed strategy Nash equilibrium/equilibria of this game.
Questions 19 and 20: Now the doctor prescribes first, then the patient complies or not: draw
the corresponding extensive-form game (= question 19) AND find the subgame perfect Nash
equilibrium/equilibria (=
View More
6.A GRAPHING CALCULATOR IS REQUIRED FOR THIS QUESTION.
You are permitted to use your calculator to solve an equation, find the
...
lve an equation, find the derivative of a function at a point, or calculate the value of a definite integral. However, you must clearly indicate the setup of your question, namely the equation, function, or integral you are using. If you use other built-in features or programs, you must show the mathematical steps necessary to produce your results. Your work must be expressed in standard mathematical notation rather than calculator syntax.
Show all of your work, even though the question may not explicitly remind you to do so. Clearly label any functions, graphs, tables, or other objects that you use. Justifications require that you give mathematical reasons, and that you verify the needed conditions under which relevant theorems, properties, definitions, or tests are applied. Your work will be scored on the correctness and completeness of your methods as well as your answers. Answers without supporting work will usually not receive credit.
Unless otherwise specified, answers (numeric or algebraic) need not be simplified. If your answer is given as a decimal approximation, it should be correct to three places after the decimal point.
Unless otherwise specified, the domain of a function f is assumed to be the set of all real numbers x for which f(x) is a real number.
Let f be a twice-differentiable function such that f′(2)=0 . The second derivative of f is given by f′′(x)=x2e2−x−1 for 0≤x≤6 .
(a) On what open intervals contained in 0
View More
9.You will implement a version of the cuckoo hash table. Your cuckoo hash will operate as follows
You will use
...
You will use a single backing array(instead of two) and two hash functions (both MultiplicativeHashFunction objects), h1 and h2.
The z values for your hash functions (and all subsequent hash functions needed when resizing or rehashing) will be taken from an array of integers passed to the CuckooHashTable constructor. The first value in the array will be used for the first incarnation of h1, the second value for the first incarnation of h2, the next two values will be used for the next incarnations of h1 and h2, etc.
Note: be careful to follow this. We will be checking your array (via toString()) and correctness will depend on using the same values of z as we do when generating the test code. The MultiplicativeHashFunction objects you will use also have a getParams() method to show the value of z,w,d when that hash function is used.
When adding an item, x, that is not in the hash table already, always add it to t[h1(x)] (even if t[h1(x)] is already taken and t[h2(x)] is available).
The load factor must always satisfy α=n/t.length≤1/2. If adding an item will violate this then resize the table (doubling its size) and rehash everything (before doing the add).
After removing an item, if the load factor satisfies α=n/t.length<1/8 AND the dimension satisfies d≥5 then resize by reducing the size of the bucket table by a factor 2 and rehash everything.
Each time you resize you will create two new hash functions using the next two z values (that were initially passed to the constructor).
Your constructor should initialize an empty bucket array of size 16 (i.e., d=4). This is the minimum size your bucket array should ever be. Never let the dimension be smaller then 4.
View More
10.Spending on health care now constitutes a significant fraction of total expenditure. Understanding the efficacy of this spending is therefore
...
he efficacy of this spending is therefore relatively important. When it comes to contagious diseases, there are generally two strategies that can be adopted. The first involves prevention, which includes vaccinations to lower or eliminate the risk of contracting a disease. The second involves treatment of those unfortunate enough to get sick, treatment typically requires some form of a drug. Since pharmaceutical companies can produce both vaccines and drugs, we would like to understand the incentives they have to develop each type of medicine. To explore this question, consider a population of 100 consumers, 90 of whom have a low disease risk, say 10%. The remaining ten have a high risk – to make things simple, assume they are certain to contract the disease. In addition, suppose the disease generates personal harm equal to the loss of $100 for each individual when they are infected. Suppose also that pharmaceuticals of either form (vaccines or drugs) are costless to produce (once R & D has occurred) and are perfectly effective
Question 2. What price would a profit maximising monopolist charge for a vaccine? What are the monopoly profits on the vaccine? What is the efficient outcome (i.e. SMB = SMC)? What is the welfare under the monopoly and at the efficient allocation?
Question 3.Now consider the demand for the drug (assume that the vaccine is not available). Construct the demand function for the drug and plot it on a diagram. What price would a profit maximising monopolist charge for the drug? What are the monopoly profits from the drug? What is the efficient outcome? What is the welfare under the monopoly and at the efficient allocation?
Question 4. If the R&D costs of the vaccine and drug are the same, what will the pharmaceutical company do? Explain your answer in terms of the variation in the willingness to pay and the size of the R& D costs. What would a social planner do?
Question 5. What are the R&D cost for the vaccine and the R&D cost for the vaccine drug that would make a pharmaceutical company indifferent between developing the vaccine and the drug? Is the social planner indifferent in this case? Explain any difference.
View More
11.To gain experience with the operations involving binary search trees. This data structure as linked list uses dynamic memory allocation
...
list uses dynamic memory allocation to grow as the size of the data set grows. Unlike linked lists, a binary search tree is very fast to insert, delete and search.
Project Description
When an author produce an index for his or her book, the first step in this process is to decide which words should go into the index; the second is to produce a list of the pages where each word occurs. Instead of trying to choose words out of our heads, we decided to let the computer produce a list of all the unique words used in the manuscript and their frequency of occurrence. We could then go over the list and choose which words to put into the index.
The main object in this problem is a "word" with associated frequency. The tentative definition of "word" here is a string of alphanumeric characters between markers where markers are white space and all punctuation marks; anything non-alphanumeric stops the reading. If we skip all un-allowed characters before getting the string, we should have exactly what we want. Ignoring words of fewer than three letters will remove from consideration such as "a", "is", "to", "do", and "by" that do not belong in an index.
In this project, you are asked to write a program to read any text file and then list all the "words" in alphabetic order with their frequency together appeared in the article. The "word" is defined above and has at least three letters.
Note:
Your result should be printed to an output file named YourUserID.txt.
You need to create a Binary Search Tree (BST) to store all the word object by writing an insertion or increment function. Finally, a proper traversal print function of the BST should be able to output the required results.
The BST class in the text can not be used directly to solve this problem. It is also NOT a good idea to modify the BST class to solve this problem. Instead, the following codes are recommended to start your program.
//Data stored in the node type
struct WordCount
{
string word;
int count;
};
//Node type:
struct TreeNode
{
WordCount info;
TreeNode * left;
TreeNode * right;
};
// Two function's prototype
// Increments the frequency count if the string is in the tree
// or inserts the string if it is not there.
void Insert(TreeNode*&, string);
// Prints the words in the tree and their frequency counts.
void PrintTree(TreeNode* , ofstream&);
//Start your main function and the definitions of above two functions.
Sample Run
Please type the text file name: Lincoln.txt
Please give the output text file name: mus11.txt
You are done! You can open the file "mus11.txt" to check.
Press any key to continue
------------------------------------------------------------------------------------------------------------------------------------------------
lincoln.txt---
The Gettysburg Address
Gettysburg, Pennsylvania
November 19, 1863
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in
Liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and
so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate
a portion of that field, as a final resting place for those who here gave their lives that that nation
might live. It is altogether fitting and proper that we should do this.
But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground.
The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add
or detract. The world will little note, nor long remember what we say here, but it can never forget what
they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they
who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great
task remaining before us -- that from these honored dead we take increased devotion to that cause for
which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not
have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government
of the people, by the people, for the people, shall not perish from the earth.
------------------------------------------------------------------------------------------------------------------------------------------------
mus11.txt
1863 1
Address 1
But 1
Four 1
Gettysburg 2
God 1
Liberty 1
November 1
Now 1
Pennsylvania 1
The 3
above 1
add 1
advanced 1
ago 1
all 1
altogether 1
and 6
any 1
are 3
battle-field 1
before 1
birth 1
brave 1
brought 1
but 1
can 5
cause 1
civil 1
come 1
conceived 2
consecrate 1
consecrated 1
continent 1
created 1
dead 3
dedicate 2
dedicated 4
detract 1
devotion 2
did 1
died 1
earth 1
endure 1
engaged 1
equal 1
far 2
fathers 1
field 1
final 1
fitting 1
for 5
forget 1
forth 1
fought 1
freedom 1
from 2
full 1
gave 2
government 1
great 3
ground 1
hallow 1
have 5
here 8
highly 1
honored 1
increased 1
larger 1
last 1
little 1
live 1
lives 1
living 2
long 2
measure 1
men 2
met 1
might 1
nation 5
never 1
new 2
nobly 1
nor 1
not 5
note 1
our 2
people 3
perish 1
place 1
poor 1
portion 1
power 1
proper 1
proposition 1
rather 2
remaining 1
remember 1
resolve 1
resting 1
say 1
score 1
sense 1
seven 1
shall 3
should 1
struggled 1
take 1
task 1
testing 1
that 13
the 9
their 1
these 2
they 3
this 4
those 1
thus 1
under 1
unfinished 1
vain 1
war 2
what 2
whether 1
which 2
who 3
will 1
work 1
world 1
years 1
View More
12.Hi! I need help with my Netlogo homework, where I need to have turtles create an image of a tree.
...
sically, Tree 1 is just a vertical line, Tree 2 is that line plus two branches, Tree 3 is Tree 2 but with two additional branches on each of the original ones, and so on. Please help! I don't understand how recursions are supposed to be used with this and how to call a previous tree function. Below are additional instructions my teacher gave me.
draw-tree3 [ levels blen bangle]
levels : number of levels
blen : length of each branch
bangle : angle of the branches
The branch length should decrease as the function calls itself. This does NOT mean you decrease a variable, it means that just like fib(n-1) or fib(n-2) you decrease the parameter as you pass it to the next copy.
----Your slider is the STARTING value, the parameter can be changed every time your function is called.
Have the branch decay by multiplying by 0.85 before passing it to the next recursive call.
-When this works, try making the branch decay a slider from 0.1 to 0.9 in increments of 0.01
View More