Hi, I would be grateful for some helot with this Python problem. Your task is to implement the simple elevator in Python using classes. The default strategy is the simple "start at the bottom, go to the top, then go to the bottom". Can you write a better strategy, one that is more efficient? Description / Specification Create three classes: Building, Elevator, and Customer. Equip the building with an elevator. Ask user to customize the number of floors and the number of customers. Program should have error checking to make sure the user inputs are valid. For example, if a user gives non-integer inputs, notify the user that the inputs are incorrect and prompt again. Each customer starts from a random floor, and has a random destination floor. Each customer will use the elevator only once, i.e., when a customer moves out of the elevator, he/she will never use it again. When all customers have reached their destination floor, the simulation is finished. Part of the grade on this assignment will be the appropriateness of your classes, methods, and any functions you use. The quality of the code will matter as well as the performance. All class methods require a docstring for a general description of the method. Implement both your own strategy and the default strategy and compare. Your strategy does not have to be better but the comparison is required. Don't use any global variables. Notes and Hints In your main function, at the beginning ask the user for the number of floors and the number of customers which can be used to create an instance of Building. Then we only need to call the run and output methods repeatedly in a while loop. Randomly select the floors (to and from) for each customer. Use the randint function from the random module. To compare efficiency of strategy, count the number of floors visited for your strategy versus the default strategy. Make a demo to create usable output from your simulation.
In: Computer Science
Suppose three players go on multiple rounds of kart race. In each round, every player has a winning probability of 1/3, independent of other rounds. let N denote the number of rounds until player 1 has two consecutive wins. Find
a.) Find P (N ≤ 10). (2 points) b.) Find P (N = 10). (2 points)
In: Statistics and Probability
A sports researcher is interested in determining if there is a relationship between the number of home team and visiting team wins and different sports. A random sample of 633 games is selected and the results are given below. Conduct test of hypothesis to test the claim that the number of home team and visiting team wins is independent of the sport. Use a=0.05.
| Football | BasketBall | Soccer | Baseball | |
| Hometeam Wins | 89 | 165 | 91 | 49 |
| Visiting Team Wins | 60 | 89 | 52 | 38 |
Please use SPSS if available to solve
In: Statistics and Probability
Question 2:
A sports researcher is interested in determining if there is a relationship between the number of home team and visiting team wins and different sports. A random sample of 633 games is selected and the results are given below. Conduct test of hypothesis to test the claim that the number of home team and visiting team wins is independent of the sport. Use α = 0.05.
|
Football |
Basketball |
Soccer |
Baseball |
|
|
Hometeam wins |
89 |
165 |
91 |
49 |
|
Visiting team wins |
60 |
89 |
52 |
38 |
In: Statistics and Probability
Coding Project 2: UDP Pinger
In this lab, you will learn the basics of socket programming for UDP in Python. You will learn how to send and receive datagram packets using UDP sockets and also, how to set a proper socket timeout. Throughout the lab, you will gain familiarity with a Ping application and its usefulness in computing statistics such as packet loss rate.
You will first study a simple Internet ping server written in the Python, and implement a corresponding client. The functionality provided by these programs is similar to the functionality provided by standard ping programs available in modern operating systems. However, these programs use a simpler protocol, UDP, rather than the standard Internet Control Message Protocol (ICMP) to communicate with each other. The ping protocol allows a client machine to send a packet of data to a remote machine, and have the remote machine return the data back to the client unchanged (an action referred to as echoing). Among other uses, the ping protocol allows hosts to determine round-trip times to other machines.
You are given the complete code for the Ping server below. Your task is to write the Ping client.
Server Code
The following code fully implements a ping server. You need to compile and run this code before running your client program. You do not need to modify this code.
In this server code, 30% of the client’s packets are simulated to be lost. You should study this code carefully, as it will help you write your ping client.
# UDPPingerServer.py
# We will need the following module to generate randomized lost
packets import random
from socket import *
# Create a UDP socket
# Notice the use of SOCK_DGRAM for UDP packets
serverSocket = socket(AF_INET, SOCK_DGRAM)
# Assign IP address and port number to socket
serverSocket.bind(('', 12000))
while True:
# Generate random number in the range of 0 to 10
rand = random.randint(0, 10)
# Receive the client packet along with the address it is coming
from message, address = serverSocket.recvfrom(1024)
# Capitalize the message from the client
message = message.upper()
# If rand is less is than 4, we consider the packet lost and do not respond if rand < 4:
continue
# Otherwise, the server responds
serverSocket.sendto(message, address)
The server sits in an infinite loop listening for incoming UDP packets. When a packet comes in and if a randomized integer is greater than or equal to 4, the server simply capitalizes the encapsulated data and sends it back to the client.
Packet Loss
UDP provides applications with an unreliable transport service. Messages may get lost in the network due to router queue overflows, faulty hardware or some other reasons. Because packet loss is rare or even non-existent in typical campus networks, the server in this lab injects artificial loss to simulate the effects of network packet loss. The server creates a variable randomized integer which determines whether a particular incoming packet is lost or not.
Client Code
You need to implement the following client program.
The client should send 10 pings to the server. Because UDP is an
unreliable protocol, a packet sent from the client to the server
may be lost in the network, or vice versa. For this reason, the
client cannot wait indefinitely for a reply to a ping message. You
should get the client wait up to one second for a reply; if no
reply is received within one second, your client program should
assume that the packet was lost during transmission across the
network. You will need to look up the Python documentation to find
out how to set the timeout value on a datagram socket.
Specifically, your client program should
(1) send the ping message using UDP (Note: Unlike TCP, you do not
need to establish a connection first, since UDP is a connectionless
protocol.)
(2) print the response message from server, if any
(3) calculate and print the round trip time (RTT), in seconds, of
each packet, if server responses
(4) otherwise, print “Request timed out”
During development, you should run the UDPPingerServer.py on your machine, and test your client by sending packets to localhost (or, 127.0.0.1). After you have fully debugged your code, you should see how your application communicates across the network with the ping server and ping client running on different machines.
Message Format
The ping messages sent to the server in this project are formatted in a simple way. The client message is one line, consisting of ASCII characters in the following format:
Ping sequence_number time
where sequence_number starts at 1 and progresses to 10 for each successive ping message sent by the client, and time is the time when the client sends the message.
------------------------------------
I cannot get my version to work, please follow the instructions.
In: Computer Science
An all-pay auction is a type of auction which allocates the good to the player with the highest bid, and where all bidders pay their bid (even if they lose). Suppose that there are two bidders, with private valuations uniformly distributed on the interval 0 to 1. A bidder who wins the auction has a payoff of vi ? bi. A bidder who loses the auction has a payoff of ?bi. a. Suppose that player 2 pays the bidding strategy b2 (v2) = ? (v2)2 , where ? is a positive constant we will solve for in a later part of the problem. If player 1 has a bid equal to b1 what is the probability that it will win the auction?
b. If player 1 has a bid equal to b1 and valuation equal to v1, what are its expected payoffs?
c. Find player 1’s payoff-maximizing bidding strategy.
d. Using your answer to part c, solve for ?. (Hint: Your answer to part c should be b1 = ?v12 for some number ? > 0. Equate ? and ? to solve for the ? that we conjectured in part a.)
e. What are the seller’s expected revenues of this auction?
In: Economics
An all-pay auction is a type of auction which allocates the good to the player with the highest bid, and where all bidders pay their bid (even if they lose). Suppose that there are two bidders, with private valuations uniformly distributed on the interval 0 to 1. A bidder who wins the auction has a payoff of vi ? bi. A bidder who loses the auction has a payoff of ?bi. a. Suppose that player 2 pays the bidding strategy b2 (v2) = ? (v2)2 , where ? is a positive constant we will solve for in a later part of the problem. If player 1 has a bid equal to b1 what is the probability that it will win the auction?
b. If player 1 has a bid equal to b1 and valuation equal to v1, what are its expected payoffs?
c. Find player 1’s payoff-maximizing bidding strategy.
d. Using your answer to part c, solve for ?. (Hint: Your answer to part c should be b1 = ?v12 for some number ? > 0. Equate ? and ? to solve for the ? that we conjectured in part a.)
e. What are the seller’s expected revenues of this auction?
In: Economics
Two players (player A and player B) are playing a game against each other repeatedly until one is bankrupt. When a player wins a game they take $1 from the other player. All plays of the game are independent and identical. Suppose player A starts with $6 and player B starts with $6. If player A wins a game with probability 0.5, what is the probability the game ends (someone loses all their money) on exactly the 10th play of the game?
In: Math
In a game of “Chuck a luck” a player bets on one of the numbers 1 to 6. Three dice are then rolled and if the number bet by the player appears i times (where i equals to 1, 2 or 3) the player then wins i units. On the other hand if the number bet by the player does not appear on any of the dice the player loses 1 unit. If x is the players’ winnings in the game, what is the expected value of X?
a) Let x denote the players’ winnings in the game. Find the probability distribution of x and draw a graph of the probability distribution.
b) What is the probability that the player will win at least 2 units?
c) What is the expected value and the standard deviation of X?
d) In light of the results you obtained above, will you play this game? Explain your answer.
In: Statistics and Probability
Suppose you wanted to predict Winnings ($) using only the number of poles won (Poles), the number of wins (Wins), the number of top five finishes (Top 5), or the number of top ten finishes (Top 10). Which of these four variables provides the best single predictor of winnings?
In: Statistics and Probability