Questions
Part A - For Loops (7 Marks) Charlie, an avid mountain biker, has purchased a new...

Part A - For Loops

Charlie, an avid mountain biker, has purchased a new multisport watch that measures data such as horizontal position, time, heart rate and elevation. The associated software for the watch allows for users to design their own apps that record new measurements. Charlie is interested in measuring their elevation gain and total distance travelled.

1. Write a MATLAB function that recieves vectors for horizontal position and elevation and outputs a plot of elevation vs. horizontal position. (1 mark)

2. Write a function that receives the vectors for horizontal position and elevation and outputs total distance travelled. You can assume that each point has been recorded sufficiently close together that a linear approximation incurs insignificant error. Your solution must use a for loop and is not allowed to use the in-built sum or diff functions. Hint: Calculate the distance between each coordinate and sum these distances together.

3. Elevation gain is a term used to describe the total vertical distance climbed up during uphill sections (downhill elevation changes are ignored). Write a function that receives an elevation vector and calculates the total elevation gain for the trip. Your solution must use a for loop and is not allowed to use the in-built sum or diff functions.

In: Computer Science

Python: Write a function that receives a one dimensional array of integers and returns a Python...

Python:

Write a function that receives a one dimensional array of integers and returns a Python tuple with two values - minimum and maximum values in the input array. You may assume that the input array will contain only integers and will have at least one element. You do not need to check for those conditions.

Restrictions: No built-in Python data structures are allowed (lists, dictionaries etc). OK to use a Python tuple to store and return the result.

Below is the starter skeleton code for this problem, on which the implementation must be built. Methods defined in the skeleton code must retain their names and input / output parameters. Variables defined in skeleton code must also retain their names.

from a1_include import

*def min_max(arr: StaticArray) -> ():

"""

TODO: Write this implementation

"""

return 0, 0

# BASIC TESTING

if __name__ == "__main__":

# example 1

arr = StaticArray(5)

for i, value in enumerate([8, 7, 6, -5, 4]):

arr[i] = value

print(min_max(arr))

# example 2

arr = StaticArray(1)

arr[0] = 100

print(min_max(arr))

# example 3

arr = StaticArray(3)

for i, value in enumerate([3, 3, 3]):

arr[i] = value

print(min_max(arr))

In: Computer Science

A bond with a face value of $1000 and maturity of exactly 20 years pays 10%...

A bond with a face value of $1000 and maturity of exactly 20 years pays 10% annual coupon. This bond is currently selling at an annual yield-to-maturity (YTM) of 12%. Answer the following questions for this bond.

a. Calculate the current price of the bond by discounting all the cash flows of the bond using the timeline method. b. Calculate the modified duration of the bond without using any Excel built-in function. (calculate PV of each cash flow, find the weight of each cash flow and then multiply time with the weight) c. Using modified Duration, calculate what would be the new price of the bond when YTM is 11%. d. Using modified Duration, what is the percentage change in price from the original level (found in part a) when YTM is 11%? e. Calculate convexity of the bond without using any Excel built-in function. f. Using the modified duration plus convexity model, what is the new price of the bond when YTM is 13%? g. Using the modified duration plus convexity model, what is the percentage price change from the original level (found in part a) of the bond when YTM is 13%.

Please only answer parts E,F & G

In: Finance

Provide the optimal Solution to the problems below using java code and include Time Complexity Analysis!...

Provide the optimal Solution to the problems below using java code and include Time Complexity Analysis!

  1. Peaks and Valleys

In an Array of integers, a “peak” is an element which is greater than or equal to the adjacent integers and a “valley” is an element which is less than or equal to the adjacent integers. For example, the array {5, 8, 6, 2, 3, 4, 6}, {8, 6} are peaks and {5, 2} are valleys. Give an array of integers, sort the array into an alternating sequence of peaks and valleys.

EXAMPLE

INPUT:

                                {5, 3, 1, 2, 3}

                OUTPUT:

{5, 1, 3, 2, 3}

  1. Build Order

You are given a list of projects and a list of dependencies (Which is a list of pairs of projects, where the second project is dependent on the first project). All of a project’s dependencies must be built before the project is. Find a build order that will allow the projects to be built. If there is no valid build order, return an error.

EXAMPLE

                INPUT:

                                Projects: a, b, c, d, e, f

                                Dependencies: (a, d), (f ,b), (b, d), (f, a), (d, c)

                OUTPUT:

f, e, a, b, d, c

(I need java code with explanation of algorithms and time complexity)

In: Computer Science

Suppose we have the following projects on two stocks. Assume thecorrelation among the two assets...

Suppose we have the following projects on two stocks. Assume the correlation among the two assets returns is 0.6

State of EconomyProbabilityStock AStock B
Recession0.2-2%6%
Slow0.448
Average0.41219

a. Find the expected return and standard deviation of shares A and B.

b. Find the investment percentage (weights) needed in A and B shares to create the minimum variance portfolio.

In: Finance

Nicholas Matveev wants to take a year-long cycling trip throughSouth America in three years.  He will...

  1. Nicholas Matveev wants to take a year-long cycling trip through South America in three years.  He will have to pay $5,000 costs at the start of the trip and then $1,000 per month for 12 months.  Assume the monthly payments are at the end of the month.  He has $1,000 saved now.  How much must he save each month until the trip if he earns 0.2% interest per month?

In: Finance

Amy’s income is $ 10,000 and she is risk averse. The probability of someone slipping on...

Amy’s income is $ 10,000 and she is risk averse. The probability of someone slipping on her sideway is 1/8. If this happens, she will be sued for $5,000 and will have to pay that amount. She can purchase insurance at a price of $0.2 per dollar of coverage. Show how the equilibrium amount of insurance coverage is determined. If her utility of money is given as U=m0.5, where m is the money amount in a particular state, calculate the optimal insurance.

In: Economics

An insurance company believes that people can be divided into two classes: those who are accident...

An insurance company believes that people can be divided into two classes: those who are accident prone and those who are not. Their statistics show that an accident prone person will have an accident within a year with a probability of 0.4, whereas the probability for a nonaccident prone person is 0.2. It is assumed that 30% of the population is accident prone. Given that a new policyholder has an accident within a year of purchasing a policy, what is the probability that he or she is accident prone?

In: Statistics and Probability

(Tipler6 21.33★★) A charge of -1.0 µC is located at the origin, a second charge of...

(Tipler6 21.33★★) A charge of -1.0 µC is located at the origin, a second charge of 3.6 µC is located at x = 0, y = 0.1 m, and a third charge of 10 µC is located at x = 0.2 m, y = 0. Calculate the components of the forces that act on each of the three charges.

1)The x-component of the force on q = -1.0 µC:

2)The y-component of the force on q = -1.0 µC:

In: Physics

A local grocery store sells individually packaged slices of cake, all labeled with the same weight...

A local grocery store sells individually packaged slices of cake, all labeled with the same weight of 4 oz.

Suppose we take a random sample of 49 cake slices and record their weights. The mean weight of our sample of 49 slices is 4.2 oz.

Assume that the population standard deviation is 0.2 oz.

True or false? It is very likely that the actual cake slice weight mean is higher than 4 oz..

In: Statistics and Probability