The National Weather Service computes the wind chill index using the following formula:
35.74 + 0.6215T – 35.75(V0.16) + 0.4275T(V0.16)
where T is the temperature in degrees Fahrenheit, and V is the wind speed in miles per hour. Rows should represent wind speed from 0 to 50 in 5 mph increments, and the columns represent temperatures from -20 to +60 in 10 degree increments.
Create a function windChill(temperature, velocity) which will calculate and return the wind chill for a combination of temperature and wind speed. If the velocity (wind speed) is less than 3 miles per hour, the function should return the provided temperature. If the velocity is greater than or equal to 3 MPH use the formula to calculate and return the wind chill.
Your main() function should use nested loops to create the table, with repeated calls to your windChill() function to determine the value for each wind/temperature combination.
Evaluation:
Use of function to calculate wind chill
Use of nested loops (for or while) to print the rows
Format of table is important
numbers are integers and column aligned
header aligns with values
Suppose I have the following datapoints. I would like to extract the cumulative percentage distribution of this set of the three largest values.
So first step would be to transform to 100% distribution and secondly summarise the three largest values of the new distribution.
Data
0.00
1.35
11.05
24.85
37.85
15.40
6.95
1.65
0.25
I can calculate the individual percentage point with a simple datapoint / sum of datapoints per row and use =LARGE 1,2,3 on the new column to sum up the values. However, the challenge is to make all calculations in a single cell and just return just the final value.
In this case, the target value would be: 0.2494 + 0.3804 + 0.1548 = 0.7849 or 78.48%
Thanks for the help
Wrap a LARGE in SUMPRODUCT:
=SUMPRODUCT(LARGE(A2:A10,{1,2,3}))/SUM(A2:A10)
So I have a table that looks like this
Arrival Time Probability
0 .09
1 .17
2 .27
3 .2
4 .15
5 .12
And I want excel to randomly create one of the 6 arrival time values based on the given probabilities using RAND(). Is there any way to do this other than to have nested If loops?
here's what I came up with.
I would add a column C that calculates the cumulative brackets from 0-1 each digit would represent. If you start with zero and use formulas to calculate your brackets, you can change the probability if needed in the future. (formulas in photo below)
For example, arrival time of 0 would be between 0 and .09.
Then you can use use the rand() function in column D to generate your random number between 0 and 1 and add a lookup function in column E, or wherever you like. Screenshots of the data and formulas:
Replace your probabilities with cumulative probabilities (with a preliminary line for 0) and use VLOOKUP, exploiting the fact that VLOOKUP finds the closest match:
I have the following excel setup that is extremely massive but here is a simplified setup:
Site1 X-Given Y-Given Site2 X-New-Given Y-Interpolated
A 10 400 A 25 550
A 20 500 A 25 550
A 30 600 A 26 560
A 40 700 B 27 570
A 50 800 B 30 600
B 10 400 B 15 450
B 20 500 B 25 550
B 30 600 B 30 600
What I'm trying to accomplish is to have each Y-Interpolated only interpolate based upon its specific site and not have any cross over. So site A would only interpolate with site A, and same with site B... so on and so forth.
I'm using the interpolate excel addin which has the following syntax:
=interpolate(x_array,y_array,x_given)
Thanks for the help!
You could try this worksheet function alternative... with data in A1:E9, enter this in F2 and fill down:
=FORECAST(E2,IF(MMULT(ROW(B$2:B$9)-LOOKUP(0,(B$2:B$9>=E2)/(A$2:A$9=D2),ROW(B$2:B$9))-0.5,1)^2<1,C$2:C$9),B$2:B$9)
Update: Here's a slightly shorter alternative entered with CTRL+SHIFT+ENTER
=PERCENTILE(IF(A$2:A$9=D2,C$2:C$9),PERCENTRANK(IF(A$2:A$9=D2,B$2:B$9),E2,20))
This assumes a positive relationship between variables and returns values at both boundaries.
Background
If you're going to use worksheet functions for this, the obvious approach is to find the neighboring two points to X: (X1,Y1) and (X2,Y2). Then calculate Y using:
Y = Y1 + (X - X1) * (Y2 - Y1) / (X2 - X1)
The problem is that this leads to a lengthy formula involving six INDEX/MATCH combinations and six more conditions for restricting data to the specified site. This leads one to look for other options...
1. The first formula looks complicated but all it's doing is applying a straight line fit based on the two neighboring points for the same site. Evaluating the formula for the third row above - by highlighting each part of the formula and pressing F9 - gives:
=FORECAST(26,{FALSE;500;600;FALSE;...},{10;20;30;40;...})
FORECAST ignores non-numeric data so the result is the same as just using {500,600} and {20,30} for the 2nd and 3rd arguments. You can use F9 on other parts of the formula to break it down further - I'll leave details to you. (The MMULT(...,1) part just changes the argument to an array so you can enter the formula without array-entry.)
2. The second formula is easier to follow. First note that in Excel percentiles are calculated by linear interpolation and the IF part is just restricting the numeric data to the specified site. Assuming data is increasing it follows that we can find the k-value in the PERCENTILE formula that matches the lookup value in the x-range and return the y-range value with that k-value. For the example in question:
26 =PERCENTILE({10,20,30,40,50},0.4)
560 =PERCENTILE({400,500,600,700,800},0.4)
To calculate the value of 0.4 the PERCENTRANK can be used which is inverse to PERCENTILE:
0.4 =PERCENTRANK({10,20,30,40,50},26)
0.4 =PERCENTRANK({400,500,600,700,800},560)
The formula above follows by combining these two functions, the last argument is set to 20 for full precision (Excel stores values internally to around 15-17 digits of precision).
Because the tool that you're using is based on a .xll add in for excel, you(or we) can not modify the code or create a custom version of interpolate that allows adding conditions.
Instead, you'll have to filter your data apart and then run the custom-function on the filtered datasets.
I am a bit stumped with this issue, I was wondering if anyone could suggest a solution. In Excel I have a table which looks like this:
1 2 3 4 5 Result Score
80% 85% 90% 95% 100% 92.5% 3.50
What I am trying to calculate is that proportional score, based on where the result falls within the preset decimal 1-5 score.
Thanks.
In your case where each increment is 5% you could use a simple calculation like
=MAX(0,F2-75%)*20
[where result is in F2]
....but assuming that you want to interpolate the score given potentially less linear values in your table try this formula where your table is in A1:E2
=LOOKUP(F2,A2:E2,A1:E1+(F2-A2:D2)*(B1:E1-A1:D1)/(B2:E2-A2:D2))
for linear interpolation this would be general formula, just name the ranges or replace with cell references:
= (perc - minperc) / (maxperc - minperc) * (maxscore - minscore) + minscore