Jump to content

Wikipedia:Reference desk/Archives/Mathematics/2006 July 14

From Wikipedia, the free encyclopedia
Humanities Science Mathematics Computing/IT Language Miscellaneous Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions at one of the pages linked to above.

< July 13 Mathematics desk archive July 15 >


Java: fetching directory entries one-by-each over slow IO?

[edit]

I'm working on a Java problem which involves backing a JTree with a custom TreeModel showing filesystem hierarchies implementing lazy-loading of its contents. As one of the constraints, I was told the file nodes have to be added as soon as they are available to add, one at at time, rather than all at once. Yes, there is a File.getFiles() method, but even if you use that, you have to notify one at a time. (Presumably listFiles() was meant.) My question is this: how can I get the contents of a directory one-by-each? If the directory is accessible over a bog-slow network link, is there a way to have the file-reading thread notice when another directory entry is returned? As it is, listFiles() returns a File[] in bulk when it's all done; between making that call and its return, there's no partial result to put into the TreeModel.

Is there some method of reading directories that would allow me to do this? Or is the best I can do just to add the new file nodes to the tree one-by-each, instead of en masse? (I'm looking for something like the readdir() interface in the standard C library, which would allow for interruption after returning each directory entry.) grendel|khan 05:47, 14 July 2006 (UTC)[reply]

Looks the requirements are for form over function. If you can't use JNI how about Runtime.exec("ls [dir]") and read the output stream?EricR 17:06, 14 July 2006 (UTC)[reply]
What I had was apparently good enough. I remember dealing with a situation involving directories containing forty thousand files each; the readdir() API was the only way we could deal with them. I'm just a bit surprised that Java doesn't have a way of dealing with this problem natively. grendel|khan 01:22, 15 July 2006 (UTC)[reply]

Homogenity in statistics

[edit]

I am reading through Rind et all, page 32, and I am confused by his use of the term homogenity. I have read the articles on homogenity, chi-square distributions, and chi-square tests, but I am still a little bit confused about this. My current knowledge of statistics is not what I wish it was, and mostly comes from a probability course and what I could gather from wikipedia.

  • What does it mean to say that a groups of samples in a meta-analysis are not homogenous when looking at the relationship between two variables?
  • How does homogenity compare to variance, effect size, and covariance?
  • Why does removing the outliers improve homogenity, even if it leaves the effect size and 95% confidence interval the same?
  • What does the pearson chi-squared test measure?
    • How does it relate to the pearson correlation coeficient?

--Crazywolf 04:01, 14 July 2006 (UTC)[reply]

I just tried to read the article Homogeneity, and am sorry to have to report that it seemed like abracadabra to me. I can sympathize with you if you're still a little bit confused. --LambiamTalk 14:35, 14 July 2006 (UTC)[reply]
HELP! I have taught statistics at a reasonably advanced level, and yet I find the article Homogeneity to be close to fluent gibberish - if there are any people here with expertise in statistics, I would REALLY value their views on this article. Madmath789 22:22, 14 July 2006 (UTC)[reply]

help,,maths sequence

[edit]

i have this sequence i have bin given to solve and i have no idea on how to solve it..the series is 50,350,3850,and you are to find the next three numbers..i am unable to find a pattern but there is as i am told so..please is there genius who can solve it

It's multiplying by consecutive prime numbers. So 7,11 are the products here, and the next three products would be 13,17,19. At least, that is one possibility. Hope that's helpful. --Crazywolf 06:36, 14 July 2006 (UTC)[reply]
An OEIS search did not return anything for these numbers. --cesarb 18:45, 14 July 2006 (UTC)[reply]
Nonsense. Obviously, the sequence is 50, 350, and 3850 repeated over and over again. What else could it be? Or, perhaps, you add 300, then 3500, then {whatever you feel like} ad infinitum. How could there be any other interpretation? Or how about a polynomial - it could be the zeros of (x-50)(x-350)(x-3850)(x-949134431891372.8)(x-sqrt(-i)). Any other extension is absolute rubbish. Especially that "prime numbers" drivel. Where in the world did this sequence start, 5/3? Hogwash. Black Carrot 22:11, 14 July 2006 (UTC)[reply]
(In case that wasn't clear, I meant that there is no one solution to something like that, and anyone who tells you different is a fool. Any shape you can force the numbers into should be an acceptable solution. For instance, the numbers 7 and 11 aren't unique to the primes. They are also terms in the sequence "every other odd number" (3,7,11,15...), and in the sequence of solutions to the partition function (1,2,3,5,7,11...). There's nothing special about multiplication, either. You could look at what you have to add to each one. If you add 300, then 3500, do you next add 35700 and then 357900? Sure, why not? And so on.) Black Carrot 22:18, 14 July 2006 (UTC)[reply]

Three numbers is not enough to determine one, and only one, sequence, as noted above. However, I saw the multiplication by primes starting with 7 as the most obvious choice, as well, so I'd go with that. StuRat 23:11, 14 July 2006 (UTC)[reply]

Google finds this question on Yahoo Answers. – b_jonas 14:58, 19 July 2006 (UTC)[reply]

Div/0 Integration

[edit]

How would I integrate

?

I get as far as rearranging to make

, but then to integrate , I increase the index by one, but this then I get stuck, since I then of course have to divide by 0. Have I done the rearranging wrong? This question is set an example paper for Trinity College, Cambridge, so could it be a trick question? (The paper is riddled with them) smurrayinchester(User), (Talk) 07:18, 14 July 2006 (UTC)[reply]

I am afraid that your rearrangement is totally wrong. is definitely not the same as . If you cannot see how to write down the integral immediately, you might try the substitution Madmath789 07:24, 14 July 2006 (UTC)[reply]
Also, it is well known that the formula
Doesn't apply to n = -1. For this case, you have the formula:
-- Meni Rosenfeld (talk) 07:39, 14 July 2006 (UTC)[reply]
Never forget +C in indefinite integrals! (Igny 15:44, 15 July 2006 (UTC))[reply]
I don't really agree. Even with +C it's not really a precise notation. So, if we rely anyway on others understanding our intention, why do it in a more complicated way? -- Meni Rosenfeld (talk) 16:54, 15 July 2006 (UTC)[reply]
Before starting calculus, master algebra! It is correct that (1−x)2 equals 1−2x+x2. It is not correct that the reciprocal of a sum equals the sum of the reciprocals; specifically 1/(1−2x+x2) does not equal 1/1−1/(2x)+1/x2. Consider, for example, 1/(2+4); the correct answer is 16, but 12+14 equals 34, which is clearly wrong. (And even if it did work, the reciprocal of 2x is not 2/x.)
But no matter, because, … wait for it …, this is a trick question, and we have missed something important. Actually, you didn't miss it. (But Madmath789 and Meni Rosenfeld said nothing, so perhaps they did.)
As x varies from 0 to 3 the denominator crosses zero when x crosses 1, causing the function to blow up. In fact, the denominator is squared so its reciprocal is always positive. The conclusion is obvious [sic!]. --KSmrqT 09:02, 14 July 2006 (UTC)[reply]
Argh! Elementary mistake... of course you're right. Thanks! smurrayinchester(User), (Talk) 13:53, 14 July 2006 (UTC)[reply]
Just because the function blows up at x=1, does not mean the integral is undefined! You need to look at 2 integrals (from 0 to 1, and from 1 to 3) - they are both improper integrals, but I think you will find that they can both be evaluated ... Also, ignore that - not thinking straight at the moment! But in my (rather long) experience, Trinity college (and the other Cambridge colleges, for that matter) do not set trick questions - but they do set some very tricky ones! What was the exact wording of the qwuestion - did it say "evaluate" or "evaluate where/if possible"? Madmath789 09:48, 14 July 2006 (UTC)[reply]
The exact wording was "Investigate this integral", which seemed funny wording, and which is why I thought it was a trick. And given KSmrq's comments, I can see why they chose Investigate rather than evaluate or integrate. smurrayinchester(User), (Talk) 13:53, 14 July 2006 (UTC)[reply]
Aye, that's the problem with shooting from the hip: if the pistol doesn't clear the holster you can lose a toe! ;-)
As tricky questions go, this one's not that obscure. You might have been thinking of something like
which takes more careful study because of what happens around π2. Trickier still, perhaps, is an integral like
Although the limit of the function as x goes to zero is infinite, the integral is finite! (Keep this in mind before blindly trusting a numerical integrator, even an otherwise attractive choice like Romberg's method.) --KSmrqT 12:55, 14 July 2006 (UTC)[reply]

Our discontinuous integrand has its discontinuity at x=1.

This type of improper integral is convergent only if both M and N converge.

Inasmuch as the first component is a divergent integral, so is the original integral. Don't worry about N because we can stop here.--Patchouli 16:32, 14 July 2006 (UTC)[reply]

Makes sense. Thanks! Nice graph too... very helpful. smurrayinchester(User), (Talk) 17:41, 14 July 2006 (UTC)[reply]
Actually, under some definitions it's possible to integrate when both M and N (see above) are divergent; see Cauchy principal value. Conscious 18:07, 14 July 2006 (UTC)[reply]
I wouldn't put much stock in what Patchouli says; I've already given an example that contradicts the assertion. Plot a graph of tan x from 0 to 2π. Notice anything at π/2? Now consider the following facts. We define tan x as sin xcos x. Around π/2, sin x is symmetric (sin π2+x = sin π2x) and cos x is antisymmetric (cos π2+x = −cos π2x); therefore tan x is antisymmetric. The integral from 0 to π/2 diverges, as does the integral from π/2 to π. Yet since they are equal and opposite, the integral from 0 to π is 0. Changing the limits slightly, we find that
So let's review three examples I've covered in my posts and see what we can conclude.
  1. The first example is the original post, where the function blows up in the middle, the integrals on each side diverge, and the integral itself diverges.
  2. The second example is tan x, where the function blows up in the middle, the integrals on each side diverge, but we get cancellation so the full integral is finite.
  3. The third example is 1x, where the function blows up at one end, but the integral itself is finite.
Thus simplistic analyses that merely consider whether the function blows up or whether pieces of an integral diverge are not sufficient. And as the Cauchy principal value article points out, there is more than one kind of integration. In fact, the integral article lists eight different definitions! To be precise, we should stipulate that we are using, say the Henstock integral. --KSmrqT 23:06, 14 July 2006 (UTC)[reply]

Mathematically Rotate the Graph of the Exponential Function...

[edit]

Hi and thanks in advance to anyone who can help me.

As the title suggests, I'm struggling to mathematically rotate the graph of the exponential function around the y-axis. Ideally, when graphed, the new equation would have y approach zero as x approaches positive infinity and y increase to positive infinity as x approaches negative infinity.

Any advice that anyone could offer would be great.

Thanks,

A mathematically challanged student.

Do you mean you want to mirror the graph about the Y-axis ? StuRat 23:06, 14 July 2006 (UTC)[reply]
So you're trying to rotate it by 180 degrees? Well, to flip the exponential function in the x-axis, you can simply make the function negative (-(ex)), and to flip it in the y-axis, you can use a negative power (e-x). Combining them to get should work. smurrayinchester(User), (Talk) 22:14, 14 July 2006 (UTC)[reply]
in black, in pink dots
Do you mean like this? smurrayinchester(User), (Talk) 22:31, 14 July 2006 (UTC) I've read StuRat's reply, and he sounds right; that isn't a rotation but a reflection though. smurrayinchester(User), (Talk) 23:11, 14 July 2006 (UTC)[reply]
If we add a third dimension, that 2D reflection can become a rotation. (We negate z at the same time as we negate x, but since we suppress z in the plot we can't see a change in that dimension.) Anyway, to answer the initial question assuming the intent is to swap the ends of the x axis, convert exp(x) to exp(−x). --KSmrqT 23:39, 14 July 2006 (UTC)[reply]
Yes, that was my interpretation. StuRat 02:52, 15 July 2006 (UTC)[reply]

Integration by parts for Lebesgue-Stieltjes integral

[edit]

The title says it all. How does one generalize integration by parts for the Lebesgue-Stieltjes integral? I have a book that claims

where is a left-continuous version of the right-continuous function , and I would like to understand where this comes from in general. –Joke 22:25, 14 July 2006 (UTC)[reply]

Comment If you write as a continuous part and an atomic/pure jump part , this formula seems to make perfect sense. The integrals for the pure jump part form a nice telescoping series:
,
but I'd still like to know if there is a more general theory of which it is part. Thanks. –Joke 22:53, 14 July 2006 (UTC)[reply]

You guys were too slow. I found it in the (online! free!) book that was linked from Lebesgue-Stieltjes integral. It turns out that if and are regular (a function is said to be regular if at each point ) then the integration by parts may be expressed as:

,

for , obviously. The formula above follows from writing for right continuous. I'll add this stuff to the article. –Joke 03:21, 15 July 2006 (UTC)[reply]