Control Theory allows us to find various useful properties of a system such as stability. Draw a
Question:
Control Theory allows us to find various useful properties of a system such as stability. Draw a picture of a generic control system, explaining the functions of feedback and the design goals for the controller. [5 marks] (b) The Transmission Control Protocol of the Internet uses a feedback controller and responds to absence or presence of congestion signals by Additive Increase Multiplicative Decrease of a sending window. (i) Describe the operation of this scheme. [10 marks] (ii) Explain qualitatively why the scheme is necessary, but perhaps not sufficient, to create a stable set of traffic flows in the Internet. [5 marks
Consider the following randomised algorithm for the unweighted vertex cover problem: Initialize S to be the empty set For all edges e=(u,v) do If neither u nor v belongs to S Randomly choose u or v with probability 1/2 and add the verte tight as possible, on the approximation ratio of the algorithm. Hint: Try to find an invariant that bounds from below the size of the intersection of the current solution S = S(i) with the optimum solution, where S(i) denotes the set S after the i-th iteration of the FOR loop. [9 marks] 2 CST2.2017.7.3 2 Advanced Graphics (a) Briefly explain the global illumination methods radiosity and photon mapping. Highlighting the strengths and weaknesses of each method, compare and contrast the two. You will be marked for correctness, clarity and brevity. [8 marks] Recall that the signed distance field (SDF) expression of a surface returns the signed nearest distance from a sample point to the surface. This is well-suited to ray-marching on a GPU. As an example, the SDF method describing a unit cube centred at the origin may be written in openGL shading language (GLSL) as: float cube(vec3 pt) { return max(abs(pt.x), max(abs(pt.y), abs(pt.z))) - 1; } (b) Give an SDF method cylY(pt, len, radius) for a finite cylinder of specified length and radius, centred at the origin, parallel to the Y axis. [4 marks] (c) Give an SDF method hollowedSphere(pt) which specifies the model shown in Figure 1: a unit sphere hollowed along each axis by a cylindrical hole of radius 0.5. [6 marks] (d) How would you repeat your hollowed sphere at two-unit intervals infinitely across the XZ plane as illustrated in Figure 2? [2 marks] Figure 1: A unit sphere hollowed along each axis by a hole of radius 0.5 Figure 2: The hollowed unit sphere infinitely repeated in XZ at intervals of 2 Ground plane is for illustration only 3 (TURN OVER) CST2.2017.7.4 3 Machine Learning and Bayesian Inference (a) For random variables (RVs) A1, A2 and B, define what it means for A1 to be conditionally independent of A2 given B, written A1 A2|B. [1 mark] (b) Given mutually disjoint sets X1, X2 and Y of random variables from some Bayesian network, define what it means to say that a path from x1 X1 to x2 X2 is blocked by Y . [5 marks] (c) Given mutually disjoint sets X1, X2 and Y of random variables from some Bayesian network, define what it means for X1 and X2 to be d-separated by Y . What does this tell you about the probability distribution represented by the Bayesian network? [3 marks] (d) Consider the following Bayesian.
import time import pandas as pd import numpy as np
# lists of data used at variouse stages CITY_DATA = { 'chicago': 'chicago.csv', 'new york': 'new_york_city.csv', 'washington': 'washington.csv' } CITIES = ['chicago', 'new york', 'washington'] MONTHS = ['january', 'february', 'march', 'april', 'may', 'june'] DAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ] DAYS1 = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday','Sunday' ] N = 60 # used for forming dotted line
def getInput(msg, userList): while True: y = 1 print(" t ",msg) for x in userList: print(" t",y,". ",x,sep='',end='') y+=1 print(" t",y,". All ",sep='',end='') print(" t Your chocie >> ",end='') y = int(input()) if y >=1 and y<=len(userList)+1 : if y == len(userList)+1: userData = 'all' else: userData = userList[y-1].lower() break return userData
def getChoices(): # getting user input for city (chicago, new york city, washington). # Using a while loop to handle invalid inputs while True: y=1 print(" Select CITY : ") for x in CITIES : print(" t ",y,". ",x,sep=' ',end='') y += 1 print(" t Enter choice number >> ",end='') y= int(input()) if y>=1 and y<= len(CITIES) : break city = CITIES[y-1]
# get user input for month (all, january, february, ... , june) month = getInput('Select Month ', MONTHS)
# get user input for day of week (all, monday, tuesday, ... sunday) day = getInput('Select Day of Week ', DAYS)
print('-'*N) return city, month, day
def loadData(city, month, day): """ Loads data for the specified city and filters by month and day if applicable. """
# load data file into a dataframe df = pd.read_csv(CITY_DATA[city])
# convert the Start Time column to datetime df['Start Time'] = pd.to_datetime(df['Start Time'])
# extract month and day of week and hour from Start Time to create new columns df['month'] = df['Start Time'].dt.month df['day_of_week'] = df['Start Time'].dt.day_name() df['hour'] = df['Start Time'].dt.hour
# filtered by month if applicable if month != 'all': month = MONTHS.index(month) + 1 df = df[ df['month'] == month ]
# filter by day of week if applicable if day != 'all': print(day.title()) # filter by day of week to create the new dataframe df = df[ df['day_of_week'] == day.title()] return df
def timeStats(df): """ Displays statistics on the most frequent times of travel. most common month most common day of week most common hour of day
"""
print(' Calculating The Most Frequent Times of Travel... ') # display the most common month most_common_month = df['month'].value_counts().idxmax() print("The most common month is :", most_common_month)
# display the most common day of week most_common_day_of_week = df['day_of_week'].value_counts().idxmax() print("The most common day of week is :", most_common_day_of_week)
# display the most common start hour
most_common_start_hour = df['hour'].value_counts().idxmax() print("The most common start hour of day is :", most_common_start_hour) print('-'*N)
def stationStats(df): """ Displays statistics on the most popular stations and trip. most common start station most common end station most common trip from start to end (i.e., most frequent combination of start station and end station)
"""
print(' Calculating The Most Popular Stations and Trip... ')
# display most commonly used start station most_common_start_station = df['Start Station'].value_counts().idxmax() print("The most commonly used start station :", most_common_start_station)
# display most commonly used end station most_common_end_station = df['End Station'].value_counts().idxmax() print("The most commonly used end station :", most_common_end_station)
# display most frequent combination of start station and end station trip most_common_start_end_station = df[['Start Station', 'End Station']].mode().loc[0] print("The most commonly used start station and end station : {}, {}" .format(most_common_start_end_station[0], most_common_start_end_station[1])) print('-'*N)
def tripDurationStats(df): """ Displays statistics on the total and average trip duration. total travel time average travel time """
print(' Calculating Trip Duration... ')
# display total travel time total_travel = df['Trip Duration'].sum() print("Total travel time :", total_travel)
# display mean travel time mean_travel = df['Trip Duration'].mean() print("Average travel time :", mean_travel)
# display mean travel time max_travel = df['Trip Duration'].max() print("Max travel time :", max_travel)
print("Travel time for each user type: ") # display the total trip duration for each user type group_by_user_trip = df.groupby(['User Type']).sum()['Trip Duration'] for index, user_trip in enumerate(group_by_user_trip): print(" {}: {}".format(group_by_user_trip.index[index], user_trip))
print('-'*N)
def userStats(df): """ Displays statistics on bikeshare users. counts of each user type counts of each gender (only available for NYC and Chicago) earliest, most recent, most common year of birth (only available for NYC and Chicago)
"""
print(' Calculating User Stats... ')
# Display counts of user types print("Counts of user types: ") user_counts = df['User Type'].value_counts() # iteratively print out the total numbers of user types for index, user_count in enumerate(user_counts): print(" {}: {}".format(user_counts.index[index], user_count)) print()
if 'Gender' in df.columns: userStatsGender(df)
if 'Birth Year' in df.columns: userStatsBirth(df)
print('-'*N)
def userStatsGender(df): """Displays statistics of analysis based on the gender of bikeshare users."""
# Display counts of gender print("Counts of gender: ") gender_counts = df['Gender'].value_counts() # iteratively print out the total numbers of genders for index,gender_count in enumerate(gender_counts): print(" {}: {}".format(gender_counts.index[index], gender_count)) print()
def userStatsBirth(df): """Displays statistics of analysis based on the birth years of bikeshare users."""
# Display earliest, most recent, and most common year of birth birth_year = df['Birth Year'] # the most common birth year most_common_year = birth_year.value_counts().idxmax() print("The most common birth year:", most_common_year) # the most recent birth year most_recent = birth_year.max() print("The most recent birth year:", most_recent) # the most earliest birth year earliest_year = birth_year.min() print("The most earliest birth year:", earliest_year)
def tableStats(df, city): """Displays statistics on bikeshare users.""" print(' Calculating Dataset Stats... ') # counts the number of missing values in the entire dataset number_of_missing_values = np.count_nonzero(df.isnull()) print("The number of missing values in the {} dataset : {}".format(city, number_of_missing_values))
# counts the number of missing values in the User Type column number_of_nonzero = np.count_nonzero(df['User Type'].isnull()) print("The number of missing values in the 'User Type' column: {}".format(number_of_missing_values))
def main(): while True: city, month, day = getChoices() df = loadData(city, month, day)
timeStats(df) stationStats(df) tripDurationStats(df) userStats(df) tableStats(df, city)
restart = input(' Do you want to rerun the program?(yes/no) ') if restart.lower() != 'yes': break
if _name_ == "_main_": main()
your own work..answer everything
Write program that prompts for and reads in a positive integer into a variable n. Your program should then sum the first n ODD integers and display the sum
Consider a birth-death queueing system with the following birth and death coefficients in which the state index represents the number of customers in the system: k = (k + 2) k = 0, 1, 2 . . . k = k k = 1, 2 . . . All other coefficients are zero. Solve for pk, the set of equilibrium probabilities for all states k, for k = 0, 1, 2 . . . State how you would find the average number of customers in the system.
Write program that prompts the user to enter integers in the range 1 to 50 and counts the occurrences of each integer. The program should also prompt the user for the number of integers that will be entere
Write program that will ask the user for integers and print if the integer is positive, negative or zero. The program should continue asking for integer until the user enters a negative value.
Evil Robot hates kittens. He has invented the kitty-destroyer (KD) to rid the world of their menace. To test it, he has a kitten (K) next to the KD on his laboratory bench (B). He has to open the KD, place the kitten inside it, close it and press the start button (SB). He has not however established that this sequence of events will lead to his goal of a destroyed kitten. Evil Robot is equipped with a planning system based on a solver for constraint satisfaction problems, and wants to use this to construct a plan. (a) Explain how this problem can be represented using the state-variable representation, including in your answer specific examples of a domain, a rigid relation, a state variable and an action for the problem. [7 marks] (b) Give one reason that a state-variable representation might be preferable to a representation aimed at encoding to a satisfiability problem. [1 mark] (c) Explain, giving a specific example for this problem, how the action taken at some time t can be encoded as part of a constraint satisfaction problem. [3 marks] (d) Explain, giving a specific example for this problem, how a state-variable can be encoded as part of a constraint satisfaction problem. [4 marks] (e) Explain, giving a specific example for this problem, how a precondition for an action can be encoded as part of a constraint satisfaction problem. [5 marks] 3 (TURN OVER) CST.2012.8.4 3 Comparative Architectures (a) Two independent threads are run on different processors in a chip-multiprocessor. Each thread simply increments a private counter one million times. The two counters are stored in consecutive memory locations. It is discovered that running the threads sequentially is faster than running them in parallel. What may cause this type of behaviour? [5 marks] (b) Cache coherence protocols are classified as either invalidate or update protocols. What are the potential advantages and disadvantages of adopting an update rather than an invalidate protocol? [5 marks] (c) Sequential consistency offers a simple and intuitive memory consistency model. Why is sequential consistency rarely supported by modern chip-multiprocessor designs? [5 marks] (d) What information does the directory provide in a directory-based coherence protocol? [5 marks] 4 CST.2012.8.5 4 Computer Systems Modelling (a) Let U be a uniform random variable on the interval (0, 1). Show that for any continuous distribution function F(x) the random variable X defined by X = F 1 (U) has the probability distribution function F(x). [4 marks] (b) Use your result in part (a) together with a random variable U distributed according to a uniform distribution on the interval (0, 1) to construct random variables for the following two distributions: (i) the uniform distribution on the interval (a, b) where a and b are real numbers such that a < b [3 marks] (ii) the exponential distribution with parameter > 0 [3 marks] (c) Suppose that X1, X2, . . . , Xn are independent, identically distributed random variables with mean and variance 2 . Use the central limit theorem to derive an approximate 100(1 ) percent confidence interval for .
kindly answer all the questions
Human Resource Management
ISBN: 978-0538453158
13th Edition
Authors: Robert L. Mathis, John H. Jackson