I'm looking for an excel formula to generate a random range of numbers between -0.3 and +0.3. These numbers can be at most 2 decimal places.
E.g here is a list of numbers I would expect this formula to return:
-0.24, 0.02, 0.13, -0.14, 0.3, 0.22, -0.29
and so on...
Many thanks
thats quite easy to do:
=RANDBETWEEN(-30;30)/100
Related
I have a table with x,y values. I want to interpolate for a given x1 value between the y values using the hllokup function also. I have found fomrulas for vlookup and xlookup but not for hlookup. I cannot use xlookup becaus eogf the verison of excel I use.
Example:
x-values 0.2 0.5 0.8 1.0 1.25 1.5 1.75 2.0 2.5 3.0 4.0
y-values 0.1 0.11 0.12 0.15 0.18 0.2 0.23 0.24 0.28 0.31 0.32
I need the y-value for x=1.1
I appreciate any help
There are various ways to interpolate: spline, polynomial, linear and so on.
I assume that you want linear interpolation between 2 x values.
In this case first of all, you need to find closest larger and closest lower x values:
Lower x:
=MAX(IF(B1:L1<B5,B1:L1))
Larger x:
=MIN(IF(B1:L1>B5,B1:L1))
Now need to find corresponding y's with HLOOKUP.
Lower x's y:
=HLOOKUP(A9,B1:L2,2,FALSE)
Larger x's y:
=HLOOKUP(B9,B1:L2,2,FALSE)
Now that you have all needed values you can write linear interpolation formula or you can use excel formula FORECAST. With 2 x's and 2 y's it will work as linear interpolation.
=FORECAST(B5,A11:B11,A9:B9)
Formula without using helper cells:
=FORECAST(B5,CHOOSE({1,2},HLOOKUP(MAX(IF(B1:L1<B5,B1:L1)),B1:L2,2,FALSE),HLOOKUP(MIN(IF(B1:L1>B5,B1:L1)),B1:L2,2,FALSE)),CHOOSE({1,2},MAX(IF(B1:L1<B5,B1:L1)),MIN(IF(B1:L1>B5,B1:L1))))
Result:
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)
In Excel, it is possible to select a random value from a set of 5 options in the following manner:
Values
e.g. 15, 30, 50, 75, or 100
Formula
=CHOOSE(RANDBETWEEN(1,5),15,30,50,75,100)
If I wanted to select a value from a much denser range how would I do it?
e.g. 0.00, 0.01, 0.02, 0.03 ,0.04 ,0.05 ... 19.95, 19.96, 19.97, 19.98, 20.00
What would be the correct formulae?
Consider the following formula:
=0.01*RANDBETWEEN(0,2000)
This will produce random multiples of .01
Scale the output of the random function by multiplying/dividing it by a constant.
For instance, if your Random function outputs floating decimal values between 0 and 1, and you need outputs between 0 and 100, multiply the output of the random function by 100.
If you need the final result to be an integer, you can then round the value to the nearest integer.
It sounds like you want
=ROUND(RAND()*20,2)
The 20 is the maximum value of your zero-to-maximum range, and the 2 is how many decimal places it'll round the final output to.
I have a vector of values rounded to the nearest 10th, e.g
26.8, 23.3, 24.6, 27.1
I need to round each value to the nearest 0.5, in increments of 1, e.g.
26.5, 23.5, 24.5, 27.5
NOT to the nearest 0.5 in increments of 0.5, e.g.
27.0, 23.5, 24.5, 27.0
Any suggestions would be greatly appreciated. Thank you.
Cheers,
Carly
Truncate and add 0.5.
The numbers in the interval [x.000, x.999] are truncated to x.0 and then adding 0.5 puts them at x.5. This is sufficient for every interval, assuming that no extra requirements are placed on integer starting values.
Multiply your number by 2, round it, then divide by 2 back.
I am a beginner in programmin in general and R specifically.
I would like to generate a set of random numbers in a normal distribution but to limit the decimal places in these numbers to only 2.
I have been using x1 <- runif() to generate my numbers.
Can I add something to it to enable me to only get results rounded off to 2 decimal places?
You can limit the decimal places using the round() function.
If I understand your question correctly this should do the trick:
x1 <- round(
runif(5, min=0, max=1)
, digits = 2
)
x1
The results, which will be different each time, are:
[1] 0.55 0.55 0.75 0.85 0.13