Wikipedia:Reference desk/Archives/Mathematics/2010 May 24

= May 24 =

Type II error question
Hi everyone,

I've come across a question on type I and type II hypothesis errors and operating characteristics. The question is about throwing a die seven times and seeing whether or not it is biased in favour of sixes. If a six should appear more than twice after seven throws, the null hypothesis of no bias will be rejected. Hence $$H_0$$ will be accepted if the number of heads, $$X\le2$$, so if $$p$$ is the probability of getting a six, the operating characteristic is:

$$P(X\le2)=P(X=2)+P(X=1)+P(X=0)$$ $$=\binom{7}{2} p^2 \left( 1-p \right)^5+\binom{7}{1} p \left( 1-p \right)^6+ \binom{7}{0} p^0 \left( 1-p \right)^7$$ $$=\left( 1-p \right)^5 \left[ 21p^2+7p(1-p)+ \left( 1-p\right)^2 \right]$$ $$=\left(1-p\right)^5\left(15p^2+5p+1\right)$$.

Now, the next part of the question asks for what values of $$p$$ the probability of a type II error is below 10%. So, to my understanding, this means: $$\left(1-p\right)^5\left(15p^2+5p+1\right) < 0.1$$. And the answer given in the back of the book is $$p \ge 0.596$$. My question therefore is, how do I solve the above equation?  It Is Me Here   t / c 12:48, 24 May 2010 (UTC)
 * There is no general elementary way to solve such equations (polynomial of degree more than 4). You will have to use your favorite root-finding algorithm. This gives a solution of roughly 0.59618. -- Meni Rosenfeld (talk) 15:14, 24 May 2010 (UTC)
 * I don't think you should say there is no elementary way to do it without being somewhat specific about what "elementary" means. I presume you mean there's no way to express an exact solution via radicals and rational expressions.  Even then, there are some particular cases where it can be done.  Newton's method is taught in freshman calculus, and could be considered "elementary" by some reasonable standards, and can efficiently approximate the solution as closely as you want. Michael Hardy (talk) 15:24, 24 May 2010 (UTC)
 * I meant expressing the exact solution as an elementary function of the coefficients (this is a bit stronger than the Abel–Ruffini theorem, but I'm pretty sure is true). The fact that it can be found numerically to any desired precision was made clear when I linked to Root-finding algorithm, which prominently links to Newton's method. -- Meni Rosenfeld (talk) 15:57, 24 May 2010 (UTC)

It can be done numerically, for example by Newton's method. Michael Hardy (talk) 15:21, 24 May 2010 (UTC)
 * Michael, per Indentation, you should indent your post when responding to the OP. -- Meni Rosenfeld (talk) 15:57, 24 May 2010 (UTC)
 * My favorite way of solving this equation is using the p. facility of the J (programming language): p.(_0.1&p.+^&5&-.*1 5 15&p.)t.i.8 giving the real solution 0.59618 and the three pairs of complex conjugate solutions -0.161047±0.192107i, 0.932117±0.338753i, and 1.26417±0.173436i. Bo Jacoby (talk) 21:29, 24 May 2010 (UTC).


 * Ah, OK, thanks, everyone. One more question. When I choose $$x_0=0.5$$, I get to 0.59618 fine, but with $$x_0=0.9$$, $$x_1=-10$$ - what is happening in the latter case?  It Is Me Here   t / c 21:35, 25 May 2010 (UTC)
 * Newton's method does not always converge. The roots of the polynomial x2+1 are +i and &minus;i because (x&minus;i)(x&minus;(&minus;i))=x2+1. So if your initial guess is a real number the method cannot decide which one of the two roots it should converge to. Bo Jacoby (talk) 12:43, 27 May 2010 (UTC).
 * Right, Newton's method doesn't always converge (which is why the bisection method can be more robust). But in this case, it does - you just need 55 iterations. -- Meni Rosenfeld (talk) 13:12, 27 May 2010 (UTC)
 * The Durand–Kerner method method is good. I don't know the method behind the p. program, though. Bo Jacoby (talk) 15:40, 27 May 2010 (UTC).

Probability in a deck of cards
In the game of Hearts, all 52 cards are dealt; each player receives thirteen cards. What's the probability of being dealt the same value card in all four suits? I'm not sure that "value" is correct; my idea is getting what poker would call "four of a kind". I've never been able properly to figure out probability, so I haven't a clue to the answer except "not very much". Nyttend (talk) 13:46, 24 May 2010 (UTC)
 * By simulation, the probability for a given player to have four of a kind when dealt 13 cards is roughly 3.4%.
 * The standard terminology for what you called value is "rank". -- Meni Rosenfeld (talk) 15:01, 24 May 2010 (UTC)
 * The exact number is $$\frac{1357355571}{39688347475}\approx0.0342004$$. -- Meni Rosenfeld (talk) 15:33, 24 May 2010 (UTC)
 * Thanks. Can you point me to an article that would help me figure out how to calculate such things in the future?  I'm always wondering about probabilities and would like to be able to calculate them myself.  I've looked at the "Mathematical treatment" section of Probability and don't quite see how it's helpful here.  Nyttend (talk) 17:05, 24 May 2010 (UTC)
 * What you need for these calculations is combinatorics (in particular enumerative combinatorics). Combinatorial principles has some pointers, but you'll probably need a good book which explains the theory and has many examples and exercises. A quick search came up with this as a candidate.
 * Note also that this problem would have taken me a lot of time if I hadn't outsourced some of the thinking to my computer. Familiarity with some programming environment will help with the difficult problems. -- Meni Rosenfeld (talk) 17:41, 24 May 2010 (UTC)
 * You might like to look at Poker probability, which won't answer your specific question but does illustrate the general approach. Qwfp (talk) 21:17, 24 May 2010 (UTC)
 * I count 52C13 = 635013559600 possible hands that can be dealt to one player. Using inclusion-exclusion I count 13C3 * 40C1 = 11440 hands with three four-of-a-kinds, 13C2 * (44C5 - 11C1 * 40C1) = 84674304 hands with two four-of-a-kinds, and 13C1 * (48C9 - 12C1 * 44C5 + 12C2 *40C1) = 21633003392 hands with one four-of-a-kinds, for a total of 21717689136 hands with any four-of-a-kinds.  This gives a probability of 21717689136 / 635013559600 which simplifies to the fraction MR gave above. 124.157.234.80 (talk) 19:10, 25 May 2010 (UTC)

What is it called....
The product of two numbers is the value of them being multiplied together. What is the value of one number being divided by another called?--160.36.38.197 (talk) 19:46, 24 May 2010 (UTC)
 * Quotient.--RDBury (talk) 19:49, 24 May 2010 (UTC)

Need a simple function
I'm looking for a function that never goes negative, approximates the line y=x for x>0, and approaches y=0 for x<0. I'm playing with combinations of exponentials and not having success.

I often turn to my Schaum's Mathematical Handbook when I need the formula for a function that looks a certain way, but it isn't helping me in this case. Googling for "plane curves" yields some interesting galleries, but not what I'm looking for. ~Amatulić (talk) 22:43, 24 May 2010 (UTC)


 * How about $$f(x) = \frac{x+\sqrt{1+x^2}}{2}$$? Fredrik Johansson 22:59, 24 May 2010 (UTC)


 * Ah. Yes. Thanks. I knew it was something simple. Would you believe I was just now trying to rotate a hyperbola by some angle so the left leg approaches the -x axis and the right leg approaches y=x? Perhaps what I was about to come up with may reduce to your suggestion, but I'm embarrassed by how complicated I made this problem. ~Amatulić (talk) 23:10, 24 May 2010 (UTC)
 * Yes, Fredrik's function is indeed a hyperbola. What you were trying to do is actually a good way to approach the problem. -- Meni Rosenfeld (talk) 08:27, 25 May 2010 (UTC)
 * Since you don't say you want it to have continuous derivatives or increase monotonically or anything like that, what's wrong with
 * $$y=\begin{cases}0, & x\le 0 \\ x, & x > 0 \end{cases}$$
 * 69.228.170.24 (talk) 03:42, 25 May 2010 (UTC)


 * Well, I did imply that I wanted it continuous by using the words "approximates", "approaches", and "hyperbola". I need this function to apply to another one to force all values positive by squeezing the negative values above the x=0 line. Shifting won't work because the other function is unbounded and the bounds are not known. Based on this discussion, the function I ended up with is a form of Fredrik's suggestion:
 * $$y=\frac{m x + \sqrt{4 b^2 + (m x)^2}}{2}$$
 * where m is the slope of the line for x>0 and b is the y-intercept where it curves to flat at x<0. ~Amatulić (talk) 05:49, 25 May 2010 (UTC)
 * The function you've ended up could clearly be rearranged to give a second-degree equation in x and y, i.e. the equation for some conic section. A general conic section has five free parameters ( or 'degrees of freedom' as we both have degrees in physics). Your original problem completely specified both asymptotes, using up two degrees of freedom per asymptote and leaving one free parameter. You've now decided to add a parameter to allow the slope m (but not the intercept 0) of one asymptote to vary, so you now have two free parameters m and b. Hence your function above must be the general hyperbola with asymptotes x = 0 and y = m x. So your original thoughts about rotating a hyperbola were on the right track, but Fredrik's ability to conjure a particular solution out of thin air certainly helped. Qwfp (talk) 08:55, 25 May 2010 (UTC)
 * Hmm, i haven't shown the conic section is a hyperbola rather than an ellipse… but that's 'obvious' (!) Qwfp (talk) 09:09, 25 May 2010 (UTC)
 * Fredrik Johansson's equation adds errors with the 1+. Whats wrong with the more exact $$f(x) = \frac{x+\sqrt{x^2}}{2}$$? -- SGBailey (talk) 15:11, 25 May 2010 (UTC)
 * ... which is, in effect, $$\frac{x + |x|}{2}$$, and is the exact function that the OP is trying to approximate. Possibly the OP is looking for an approximation that is not only continuous but also differentiable everywhere. Gandalf61 (talk) 15:26, 25 May 2010 (UTC)
 * And this is also exactly what 69 suggested, and the OP clarified is not what ze wants. -- Meni Rosenfeld (talk) 15:59, 25 May 2010 (UTC)
 * So $$f(x) = \frac{x+\sqrt{0.000001+x^2}}{2}$$ is continuous and differentiable everywhere and a better approximation... -- SGBailey (talk) 16:11, 25 May 2010 (UTC)
 * Presumably, the OP needs this for some practical application. Ze doesn't care that the function is differentiable in theory, but rather that it is quantitatively smooth. Your suggestion is a special case of the modified formula given by the OP, where the parameter b controls the balance between accuracy and smoothness. -- Meni Rosenfeld (talk) 17:26, 25 May 2010 (UTC)


 * For the record, I am a 'he'.
 * You are exactly right, I wanted to control the balance between accuracy and smoothness.
 * What this is for: it's one piece of a model I'm developing to characterize variations in volatility of a financial market. I have a generating function that creates a randomly oscillating volatility that looks very similar to actual data. The difference is that actual data is unbounded on one side, and bounded by zero (never goes negative) on the other. I needed this hyperbola to apply to my generating function so that it, too, is bounded on the zero side but its positive values are essentially unchanged. I anticipate this hyperbola correction will affect only a few outliers. I haven't tested it yet. —Preceding unsigned comment added by Amatulic (talk • contribs)
 * It looked like you were deliberately vague about your gender in the userpage, which is why I avoided making assumptions. -- Meni Rosenfeld (talk) 18:05, 25 May 2010 (UTC)
 * Hm... it wasn't deliberate. Maybe I should put up a picture of myself, or a link to my LinkedIn profile. Although, now that I think about it, my gender shouldn't be relevant in discussions even if it does make for awkward phrasing sometimes. ~Amatulić (talk) 18:56, 25 May 2010 (UTC)
 * Interesting discussion. What I wanted was what I came up with: an a continuous function approximating y=x when x>0 and y=0 when x<0. True, other solutions proposed above by SGBailey and Gandalf61 are more exact, but I really wanted a hyperbola. Had I started with a general equation for a hyperbola and rotated it, I may have ended up with something similar, but I suspect it would have been needlessly complicated.
 * After I posted my problem, I realized I needed a way to control the slope where x>0 and control the sharpness of the turn (the y intercept) where x=0. So I played with it until I got my version above using a slope and intercept. ~Amatulić (talk) 17:23, 25 May 2010 (UTC)
 * Yes, as Qwfp and I tried to explain, Fredrik's original suggestion is a hyperbola. So is your modified version, and 69's suggestion is a degenerate hyperbola. In fact, all hyperbolas with asymptotes 0 and $$mx$$ have one piece given by your formula (the other piece is $$y=\frac{m x - \sqrt{4 b^2 + (m x)^2}}{2}$$). So if you started with any hyperbola and rotated\stretched it, you would definitely have come up with (a special case of) your general formula. -- Meni Rosenfeld (talk) 17:36, 25 May 2010 (UTC)


 * Try $$x*(\arctan(x/a)+\pi/2)/pi$$, where 'a' governs the sharpness of the curve near the origin( use 'a=1' to start with), although the limit isn't quite right. Then $$x*N(x/a)$$  might be better if you don't mind a kink for small x.  [here, 'N' is the distribution function of the normal distribution ]. HTH, Robinh (talk) 07:28, 26 May 2010 (UTC)
 * The exponential curve y=ex is what you need, even if it is not what you asked for. Bo Jacoby (talk) 12:49, 27 May 2010 (UTC).
 * That doesn't approximate the line y=x for x>0 though. Robinh (talk) 21:35, 27 May 2010 (UTC)
 * That's what Bo meant with "not what you asked for". The idea is that for working with things that are always positive, it is often prudent to transform to their logs. The OP will need to elaborate on his particular situation if we are to know if this applies to it. -- Meni Rosenfeld (talk) 06:54, 28 May 2010 (UTC)

Line inttegral
Hi. I'm not quite understanding the concepts of a line integral--can someone help me out? The way I interpret it is that the "bottom" is some curvy or nonlinear function, rather than the x-asix. Is the correct? Also what does the notation $$\oint_C$$ mean? I tried reading the article but I think it went way over my head :) It's kinda written toward someone who knows the stuff but is looking back on it to look something up, or about the history, to be honest. 76.228.199.28 (talk) 23:12, 24 May 2010 (UTC)


 * Line integrals are typically a 3rd-semester college calculus concept, meaning you should probably know the previous 2 semesters of calculus first.
 * I find that the mathematics articles on Wikipedia are absymal from a layman's point of view; by and large they are written for other mathematicians. It's understandable that each article can't teach the reader all the math that leads up to the article topic. I consider myself middling-knowledgeable; about half the mathematics articles are useful for me to look something up, and half are gobbledygook.
 * There's a good tutorial on line integrals at http://tutorial.math.lamar.edu/Classes/CalcIII/LineIntegralsPtI.aspx which should explain most of what you want to know. ~Amatulić (talk) 23:35, 24 May 2010 (UTC)
 * We do have an intro calculus textbook project, Calculus. 69.228.170.24 (talk) 03:44, 25 May 2010 (UTC)


 * ...but the basic answer is, yes, the line integral is integrating a scalar or vector quantity that varies along a curve, instead of a function that varies along the x-axis. In a scalar line integral, for example, instead of a function y of some variable x which we integrate with respect to dx, we have a scalar function f of the distance along the curve s, which we integrate with respect to ds. You can think of the "ordinary" integral as a special case of a scalar line integral, where the curve happens to be the x-axis. Vector line integrals and complex line integrals then extend the concept further. The notation $$\oint_C$$ just means that the curve is a closed curve, so the start and end points of the line integral are the same (but the value of the integral may still depend to some extent on the path taken). Gandalf61 (talk) 08:28, 25 May 2010 (UTC)
 * Can you please expand on your parenthetical remark? I assume that by "on the path taken" you do not mean on direction around the curve, but on the start-end point chosen, or are you simply stating that it will vary based on the choice of the curve C? 124.157.234.80 (talk) 18:12, 25 May 2010 (UTC)


 * In general, the value of a line integral around a closed curve C will depend on the choice of C. But in some cases the line integral around any closed curve is always zero - see conservative field. And in other cases the value of the line integral does not depend on the exact details of C, but does depend on general topological characteristics of C - see winding number. Gandalf61 (talk) 20:36, 25 May 2010 (UTC)