Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are interested in analyzing the housing market in a given city and you have data on all houses that have recently sold as
You are interested in analyzing the housing market in a given city and you have data on all houses that have recently sold as well as their size (in square feet). In particular, you are interested in determining a valuation of a candidate house based solely on this historic data (sales price and square footage). First, you would like to remove any outliers from the historic data set. A historic sale is classified as an outlier using the following procedure: Select the home to test from the historic data set Create a list of prices of other homes of the exact same size. It will be called comparison List in the examples. If there are zero houses of the same size, the house being tested is not an outlier. . Otherwise: Calculate the average price, H. and the standard deviation, a, for the homes in the comparisonList. If | price[i]-| >3*a, then the house is an outlier. Once the outliers have been removed, then the valuation of the candidate house can be calculated as follows: If there are no houses remaining in the historic list, use 1000 as the price. If there is only 1 house in the list, its price is used. If there are 1 or more houses in the list with the exact square footage of the house to price, use the average of those prices. If the required square footage is between the square footage of two houses in the list, linearly interpolate the square foot price using the means of the closest higher and lower-priced homes. If the required square footage is outside of the range of houses listed, linearly extrapolate the price based on the means of the two square footage values that are closest to the home to value. in all cases, if the final price is less than 103 or greater than 106, the price will be 103 and 106, respectively. In all cases, the returned value should be rounded to the nearest whole integer. To interpolate or extrapolate a point (x, y) when x is known from the points (X.) and (x2.) the following formula can be used: y = y + (x-x)*(V2-Y1)/(x2-x1) For example, there are n = 6 houses with area = [1200, 1300, 1200, 1300, 1200, 2000), price=[12000, 24000, 14000, 22000, 13000, 30000] and the house to value has reqArea = 1500 square feet. The following table shows the test for outliers: To Test area/price 1200/12000 1300/24000 1200/14000 1300/22000 1200/13000 2000/30000 compList [14000, 13000] [22000] [12000, 13000] [24000] [12000, 14000] Constraints 0 P[m] 13500 22000 12500 500 reqArea 105 24000 13000 NIL O 500 0 500 500 area[i] 105 for all i such that 0i Input Format For Custom Testing Sample Case 0 Sample Input For Custom Testing STDIN 1200 5 1500 500 1000 2000 2500 5 30000 10000 20000 40000 50000 Function 24000 reqArea = 1200 area [] size n = 5 area = [1500, 500, 1000, 2000, 2500] price[] size n = 5 price = [30000, 10000, 20000, 40000, 50000] Sample Output Explanation 1000 and 1500 are the closest smaller and larger areas for 1200. The candidate house value is 20000 + (1200-1000) * (30000- 20000)/(1500-1000). Sample Case 1 Language Python 3 Environment Autocomplete Ready 1> #!/bin/python3.** 10 # 11 12 13 # The function is expected to return a LONG_INTEGER. 14 # The function accepts following parameters: 15 # 1. LONG INTEGER reqArea 16 # 2. LONG INTEGER_ARRAY area 17 # 3. LONG INTEGER_ARRAY price 18 # 19 20 21 22 > if # Complete the findValuation' function below. # def findValuation (reqArea, area, price): #write code here name__ == '__main__':-. O G ...
Step by Step Solution
★★★★★
3.56 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
To implement the findValuation function according to the provided description you can follow these steps in Python Create a function findValuation that takes three parameters reqArea area and price Fi...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started