TRENDING NEWS

POPULAR NEWS

How Do You Test If A Series Of Integers Are From A Uniform Distribution

Uniform probabilities distribution, check my answers please?

An airline quotes a flight time of 2 hours, 5 minutes for a flight. Suppose we believe that actual flight times are uniformly distributed between 2 hours and 2 hours, 20 minutes.

a. What is the probability that the flight will be no more than 5 minutes late?

----My answer is 0.55

b. What is the probability that the flight will be more than 10 minutes late?

---My answer is 0.20

c. What is the expected flight time?

---My answer is (140+120)/2 = 130


Can you please tell me if my answers are correct or what I am doing wrong? Thanks!

What is the probability of an integer selected from the uniform distribution on [math][1,60000][/math] not having the digit 6?

Let's just fill up all 5 digits with zeroes for simplicity (we are not adding 6’s, that would mess things up). Let's also add 0 and remove 60,000 to keep things neat. We'll worry about them later.The first digit is never a 6 (as I mentioned, we removed 60,000). So this is a 100% success rate.The second digit is a 6 10% of the time, so we have a 90% success rate.The third digit: idem. 90%Fourth digit: as above. 90%Fifth digit: as above: 90%So, we have a 81%*81% = 65.61% chance of finding a number without a 6 between 0 and 59,999. We need to subtract 1/60000 however, as we diagnosed 0 as a favorable case, but it should be 60,000 and a negative case.The final result is65.61% - 0.0016666..% = 65.608333…%You can express it as odds if you really need to but I'm not a fan when probabilities are close to 50% or when we need to be precise. The odds are about 2:1 for finding such numbers. The exact one would be 39365:20635 for. I'd rather just use the percentage.

Why is the variance of the discrete uniform distribution different from the continuous version?

Think about the continuous uniform[math](1,2)[/math] distribution and compare that to the discrete uniform distribution on the set [math]\{1, 2\}[/math]. Both have the same mean, 1.5, but why don’t they have the same variance? Well, for the discrete uniform, all of the probability is concentrated a full one-half unit from the middle, but for the continuous version, that is not true. The probability is spread evenly with just as much of it smeared out near the mean, zero units away, as smeared out near the edges, one-half unit away form the mean. When you think about it like this, perhaps it is less surprising that the variance of the discrete version is larger than the variance of the continuous version.We can actually say even more…Consider the discrete uniform distribution on the set [math]\{1, 2, …, n\}[/math] and the continuous uniform[math](1,n)[/math].The variance of the continuous version is [math]\frac{(n-1)^2}{12}[/math]. The variance of the discrete version is[math]\frac{2(n+1)(2n+1)-3(n+1)^2}{12} = \frac{(n-1)(n+1)}{12}[/math]The ratio of the variance of the continuous to the variance of the discrete is[math]\frac{n-1 }{n+1} = 1-\frac 2{n+1}[/math]Notice that as [math]n[/math] increases from [math]2[/math] to [math]\infty[/math], this ratio monotonically increases from [math]\frac 13[/math] to [math]1[/math]. We conclude that the two distributions become “more similar” as the number of the choices for the discrete uniform distribution grows larger.You can show the same kind of behavior if you take the continuous uniform[math](0,1)[/math] distribution and compare it to the discrete uniform on the set [math]\{0, \frac 1n, \frac 2n,\ldots, \frac {n-1}n, 1\}[/math]. The larger the value of [math]n[/math] — the more choices the discrete uniform has — the closer to the continuous distribution it becomes.

How can I perform a uniform distribution in Excel?

You can use the RAND() function. It will generate random numbers in the interval 0 - 1 (so an uniform distribution).All you need is to switch this uniform distribution in the interval that you desire. If you need an uniform distribution between a and b (so centered around (a+b)/2) you need to enter the Excel formula as RAND()*(b-a) + a.Example of uniform distribution between 2 and 6 (with formula =RAND()*4+2):

Describe a normal probability distribution. (Select all that apply.)?

-Bimodal = has two peaks. Look at the graph of a Normal distribution. There's only one peak, so the distribution is unimodal, not bimodal.

-Symmetric about the mean: yes. Half lies above the graph, half lies below.

-most of the data fall within 3 standard deviations from the mean: By the 68-95-99.7 rule, 99.7% of data falls within 3 standard deviations. So, yes.

-uniform-shaped: I'm assuming this means a uniform distribution, which looks like a straight line.

-bell-shaped: Yes. Bell-shaped or bell curve is often used to describe the Normal distribution.

-skewed to the right: Nope, see #2. The graph is perfectly symmetric with no skew.

-mean, median, and mode all equivalent: Yes.

-models discrete random variables: No. Any graph that measures discrete random variables would have chunky-looking bars. This is a smooth graph.

So, the Normal probability distribution is
-symmetric around/about the mean
-most of the data fall within 3 standard deviations from the mean
-bell-shaped
-mean, median, and mode all equivalent

Discrete uniform probability question: P (X) = P (X = x)?

My professor often writes sloppy notes and I'm not sure what he means when he says P (X) = P (X = x) for discrete uniform probabilities?

I.e. p (5) = p (5 = 5)?

:-/

If I write a function that is supposed to return random numbers, how can I write a unit test for this function?

There are four broad categories of tests you want.Does the random number generator produce the desired distribution?Typically, RNGs are designed to produce either a uniform distribution or a normal distribution. Call yours millions of times and test that the distribution fits what you want.Are all of the values return in the required range?Most RNGs either produce a value in a known range and it’s the caller’s responsibility to scale it appropriately, or they allow some parameters to be passed in to specify the range. What you can specify and how will differ depending on the distribution and whether the random numbers are integers or floating point. Call your RNG lots of times and test that none of the values returned are invalid.Are all possible values returned with an appropriate probability?There are various statistical tests, but some things to look for that are easy to test are whether certain bits always have the same value, etc. Basically, if you count the number of times a value is returned in each of two equally sized subsets of the range, they should be roughly the same, where roughly the same is of course a statistical measure. For example, if you are generating a uniform distribution of 32 bit integer values, you could keep a count of how many occurred with each bit on and off. For the low-order bit, you are keeping counts of odd and even values. All 64 of those counts should be roughly the same size with a large enough sample.Are there detectable patterns in the order of the return values?You have to work hard to avoid these. A test that is conceptually simple, but requires a lot of calls is to track every possible pair of consecutive values. The problem with this is that the storage for the data is impossibly huge and the number of calls you need is even worse. The storage scales at O(n^2) where n is the number of possible values in the range, and the number of required calls scales with O(n^3). If you’re generating a uniform distribution of 32 bit integers and want to keep a 32 bit count of each two byte sequence, you’ll need 2^68 bytes. That’s inconveniently 4 orders of magnitude larger than the address space of a 64 bit processor. And I’m not actually aware of any computers that actually have any significant fraction of that much RAM, or for that matter even disk space.

The code for generating random numbers in C++?

Standard C++ has a rather rich library of random number generators and random number distributions. In the simplest case, you may want a uniform integer distribution.

#include
#include
int main()
{
// access the hardware random number generator
     std::random_device rd;

// initiate a Mersenne twister generator using a HW random value as the seed
     std::mt19937 gen(rd());

// choose the random number distribution.
// I'll pick the uniform integer distribution from 1 to 6, inclusive
     std::uniform_int_distribution<> dis(1, 6);

// print 10 numbers using the chosen distribution and generator
     for(int n=0; n<10; ++n)
     {
// store the random number in an int
         int i = dis(gen);
// and show
         std::cout << i << ' ';
     }
     std::cout << '\n';
}

tested in Visual Studio 2010 and in gcc 4.6
also tested online: https://ideone.com/f3bi1

Full-fledged random number generation facility became part of C++ only six or seven years ago (older compilers need a special library) Since you're still studying, and most C++ courses favor obsolete language concepts, you're likely learning the C random number generation facility which is included in C++. It is a bit harder to use and is limited to uniform integer distributions only and to just one unconfigurable random number generator.

#include
#include
#include
int main()
{
// seed the C random number generator with current time as seed
// (random_device or seed_seq work better, but we are being old-school here)
     std::srand( static_cast(std::time(NULL)));
     for(int n=0; n<10; ++n)
     {
// convert the output of rand (a uniformly distributed integer on [0...RAND_MAX]
// to the range [1..6]
         int i = 1 + 6.0*rand()/(RAND_MAX-1);
         std::cout << i << ' ';
     }
     std::cout << '\n';
}

test: https://ideone.com/vVUSx

Note that you will likely encounter another approach, something like 1 + rand()%6. It is passable for simple tasks, but the uniformity of the distribution is not as good, don't use that in an online casino.

TRENDING NEWS