Adding a number to a date in excel (with an average and st dev) - excel

I have a list of dates. They're dummy data for sign up dates.
I want to add another list that is dummy data for first usage dates.
To make the dates, I used this -
=RANDBETWEEN(DATE(2017,1,1),DATE(2017,6,30))
To make the first usages dates, I'm trying this -
=C6+RANDBETWEEN(0,100)
But, I don't want to just add a random number. I want to add a number from a normal distribution with a mean of 10 and a standard deviation of 30 (without going into negatives). Is that possible?

The following will generate a random number in normal distribution with a mean of 10 and deviation of 30:
= NORM.INV(RAND(),10,30)
The easiest way I can think of to exclude negative values is to just take the absolute value of this.
= ABS(NORM.INV(RAND(),10,30))
But, as already noted, if you exclude negative numbers (no matter how you decide to exclude them), then it isn't really a normal distribution anymore.
EDIT:
Another way to exclude negative numbers is the following:
Since NORM.INV(0.37,10,30) returns a value just above 0, you can use this knowledge to change the formula to only allow random values between 0.37 and 1 to be generated:
= NORM.INV(0.63*RAND()+0.37,10,30)
However, again I must point out this isn't a true normal distribution.

Related

Excel- Generating a set of numbers with normal distribution with MIN and MAX

I want to generate a single column of 6000 numbers with a normal distribution, with a mean of 30.15, standard deviation of 49.8, minium of -11.5, maximum 133.5.
I am a total newb at this so i tried to use the following formula in a cell and than just drag it down to cell 6000:
=NORMINV(RANDBETWEEN(-11.5,133.5)/100,30.15,49.8)
It returns a value but sometimes it returns #NUM! error. Thank you!
Unfortunately NORMINV expects a probability for the argument, which must be a value in the interval (0, 1). Any parameter outside that range will yield #NUM!.
What you're asking cannot be done directly with a normal distribution since that has no constraints on the minimum and maximum values.
One approach is to use a primary column to generate the normally distributed numbers, then filter out the ones you want in the adjacent column. But this will cause even the mean (let alone higher moments) to go off quite considerably due to your minimum and maximum values not being equidistant from the mean. You could get round this by recentering the distribution and adjusting afterwards.

Random number generator not working with the sumproduct function

I would like to write a single formula that is able to calculate "n" randomly generated figures, as well as average them, where n is determined by a changing reference cell.
The current formula I am using is this:
=(SUMPRODUCT((ROW(1:6)*RAND()/ROW(1:6))/6
However, the random number is only generated once and is being used in all 6 terms. Note in this case my n=6, hence I would like six randomly generated numbers being created inside the formula.
I used the following function to establish if only one random number was being generated:
=(SUMPRODUCT((ROW(1:6)*(IF(RAND()<1-0,3;(1-0,3);0,3))/ROW(1:6))/6
The final product would always be 0,3 or 0,7 and therefore confirming the fact
If I understood correct.
You want to generate "n" different random numbers and then want to take average of these numbers. This will be ultimately a single random number as it's average of 6 different random numbers.
Let me know if it helps or you need to do some calculation with all these random number so we can suggest you an alternative.

Excel date - 8/11/2015 6:50:22.000 = 8/11/2015 6:50:22.000 = FALSE? What is happening here?

I have data from two sources that I am trying to match on date/time. The problem is that I do not get a match. So I converted the date/time to Julian and encountered something odd.
8/11/2015 6:50:22.000 42227.2849768518
8/11/2015 6:50:22.000 42227.2849768519
I have never seen this before and I do not know how it is happening. The only thing that I can think is that the date/time, as originally created and entered into the source excel files was accurate out to that digit? If that is the case, how do I make excel act like the two values are the same? Do I need to convert all of the Date/Time values to Number and strip off that tenth digit to the right and limit the values to nine digits to the right? How many digits do I need to store in order to maintain accuracy to the second?
The third decimal place represents an accuracy of 1.15741e-8 days, so if the ABSOLUTE VALUE of the difference between it and the compared value is smaller than 5.78705e-9, then that's within your accuracy requirements.
something like
=ABS(time1 - time2) < 5.78705e-9
should do the trick, returning TRUE if the two values are considered 'close enough to be classed as the same for my purposes' and FALSE if they are distinct enough.

Average using a difference from MAX in Excel

I am trying to average a column of numbers, throwing out values a specific difference from MAX. The users will not be Excel experts, so I am trying to stay away from Array formulas so they can edit the difference number based on different conditions.
=AVERAGEIF(DM7:DM34,"=>Max(DM7:DM34)-3",DM7:DM34)
This returns a #Div/0, while the MAX portion alone returns the value I need.
I think what you may require is something like:
=AVERAGEIF(DM7:DM34,">="&MAX(DM7:DM34)-3)
You might achieve some added "comfort" by changing 3 in -3 to a cell reference where the difference number would be placed/changed.

Generating random numbers with normal distribution in Excel

I want to produce 100 random numbers with normal distribution (with µ=10, σ=7) and then draw a quantity diagram for these numbers.
How can I produce random numbers with a specific distribution in Excel 2010?
One more question:
When I produce, for example, 20 random numbers with RANDBETWEEN(Bottom,Top), the numbers change every time the sheet recalculates. How can I keep this from happening?
Use the NORMINV function together with RAND():
=NORMINV(RAND(),10,7)
To keep your set of random values from changing, select all the values, copy them, and then paste (special) the values back into the same range.
Sample output (column A), 500 numbers generated with this formula:
IF you have excel 2007, you can use
=NORMSINV(RAND())*SD+MEAN
Because there was a big change in 2010 about excel's function
As #osknows said in a comment above (rather than an answer which is why I am adding this), the Analysis Pack includes Random Number Generation functions (e.g. NORM.DIST, NORM.INV) to generate a set of numbers. A good summary link is at http://www.bettersolutions.com/excel/EUN147/YI231420881.htm.
Rand() does generate a uniform distribution of random numbers between 0 and 1, but the norminv (or norm.inv) function is taking the uniform distributed Rand() as an input to generate the normally distributed sample set.
About the recalculation:
You can keep your set of random values from changing every time you make an adjustment, by adjusting the automatic recalculation, to: manual recalculate. (Re)calculations are then only done when you press F9. Or shift F9.
See this link (though for older excel version than the current 2013) for some info about it: https://support.office.com/en-us/article/Change-formula-recalculation-iteration-or-precision-73fc7dac-91cf-4d36-86e8-67124f6bcce4.
Take a look at the Wikipedia article on random numbers as it talks about using sampling techniques. You can find the equation for your normal distribution by plugging into this one
(equation via Wikipedia)
As for the second issue, go into Options under the circle Office icon, go to formulas, and change calculations to "Manual". That will maintain your sheet and not recalculate the formulas each time.
Another interesting way to do this is using the Box-Muller Method. This lets you generate a normal distribution with mean of 0 and standard deviation σ (or variance σ2) of 1 using two uniform random distributions between 0 and 1. Then you can take this Norm(0,1) distribution and scale it to whatever mean and standard deviation you want.
Here's the formula in excel for a normal(0, 1) distribution:
=SQRT(-2*LN( RAND()))*COS(2 * PI()*RAND())
Then use this formula to scale your normal distribution to mean 10 and standard deviation of 7:
Norm(µ=b, σ=a) = a*Norm(µ=0, σ2=1) + b
This would make the equation in Excel:
=7* SQRT(-2*LN( RAND()))*COS(2 * PI()*RAND()) + 10
You can read more about the math behind this Box-Muller Equation on en.Wikipedia
Note that this equation only works if you calculate the cosine function using radians.
The numbers generated by
=NORMINV(RAND(),10,7)
are uniformally distributed. If you want the numbers to be normally distributed, you will have to write a function I guess.

Resources