jake ([info]pbrane) wrote,
@ 2007-08-02 06:35:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
In contrast to my last post...
It's not that I don't love you guys... it's just hard to post (for some reason, my 6am brain wrote "poast" first... and I thought it was right - I must be hungry for some tost) these days. Roughly 8 weeks until impending fatherhood (if you want to get [info]liya_rowan a nice and practical 0'th birthday present like a pack of tushie wipes or a portable high chair, swing on over to her gift registry: here [if that link doesn't work, just go to myregistry.com and search for my first and last name]), whee!

In other news, to contrast with my last post - at work yesterday, the ability to get my job done depended on knowing what the average angle between two randomly chosen vectors in N-dimensional space (for large [but finite] N). It's not hard to figure out what the answer is if the vectors lie in the unit cube (it's O(log(N)/N), I think), but on the unit sphere is trickier (and as N grows, the disparity of the two answers is probably large). Anyone else happen to know the average dot product of two unit vectors in R^N, given an even distribution on S^N-1 ?

And now, I'm late - off yer butt, [info]pbrane! Dog must be walked, bus must be caught! Next week: World Diplomacy Championships in Vancouver, where my diplomacy scoring system (and rails app to calculate it) will be used to determine The World Champion BackstabberTM.



(16 comments) - (Post a new comment)


[info]evan
2007-08-02 03:42 pm UTC (link)
For some reason it takes ~8 seconds to load pages on your rails app. I think you need to use FastCGI.

(Reply to this) (Thread)


[info]pbrane
2007-08-02 04:00 pm UTC (link)
I'm on shared hosting (dreamhost), and I've tried to make sure that I've got it using FastCGI, but for some reason it occasionally acts like it's totally not... :\

(Reply to this) (Parent)


[info]onhava
2007-08-02 04:07 pm UTC (link)
Probably I'm being dumb and/or misunderstanding the question, but: if we say the first vector is along, say, the z-axis, then we're just asking for the average z-component of a randomly chosen vector on the sphere, right? And isn't that just zero? In other words, I would think the average angle is 90 degrees, in any number of dimensions.... Do you want the average absolute value of cos(theta), instead of just the average cos(theta)?

(Reply to this) (Thread)


[info]pbrane
2007-08-02 04:15 pm UTC (link)
Do you want the average absolute value of cos(theta), instead of just the average cos(theta)?

Yes, that's what I meant (or equally useful, the average of cos^2(theta)).

(Reply to this) (Parent)(Thread)


[info]mmcirvin
2007-08-02 04:48 pm UTC (link)
Integrate cos^N theta times area of unit S^(N-2) from zero to pi, then divide by area of S^(N-1).

I think.

I used to know what the area of S^N was back when I was in Sidney Coleman's field theory class. Now I don't but I think you can look it up.

(Reply to this) (Parent)(Thread)


[info]mmcirvin
2007-08-02 04:53 pm UTC (link)
No, no, that can't be right.

That cos^N theta should be cos^2 theta * sin^(N-2) theta. Can't ever be negative.

Uh, maybe.

(Reply to this) (Parent)(Thread)


[info]pbrane
2007-08-02 05:08 pm UTC (link)
why can't sin^(N-2)[theta] ever be negative?

(Reply to this) (Parent)(Thread)


[info]onhava
2007-08-02 05:57 pm UTC (link)
Well, it's really an absolute value |sin(theta)|: at each choice of z=cos(theta) (might as well say between 0 and 1, the other half contributes equally), you have one lower-dimensional sphere of radius sqrt(1-z^2). The area (or volume, or whatever you want to call it) of that sphere scales like (1-z^2)^((N-1)/2). So it's the integral dz of z^2 (1-z^2)^((N-1)/2) from z=0 to 1, divided by the same integral without the z^2. I think.

Sound OK? I think it's the same thing [info]mmcirvin was saying....

Mathematica tells me this is 1/(N+2).

(Reply to this) (Parent)(Thread)


[info]pbrane
2007-08-02 06:33 pm UTC (link)
Mmm, yesyes. This makes sense, and the 1/N scaling jives with my unit cube calculation.

(Reply to this) (Parent)(Thread)


[info]mmcirvin
2007-08-02 08:09 pm UTC (link)
The answer should certainly go to zero in the large N limit. More dimensions, less chance the vectors will be almost parallel.

(Reply to this) (Parent)(Thread)


[info]pbrane
2007-08-02 08:21 pm UTC (link)
Which is what the actual application deals with: I've got an algorithm which hunts for vectors, and to test it, I can feed in data which I know the answer to; then I need to see whether I'm getting close or not. Taking the (normalized) dot product gets me something, and then the question becomes "how close to 1 is 'close' when talking about the dot product of two vectors on S^N?" This discussion leads me to believe it's "anything much bigger (esp. parametrically) than 1/N is 'close'".

(Reply to this) (Parent)


[info]pbrane
2007-08-02 06:40 pm UTC (link)
But should the distribution of choices of z-coordinate of the second vector be uniform on [0,1]? This is the part I'm not sure about - do uniformly distributed points on the sphere have uniform z-coordinates on [-1,1]? Is there an obvious thing I'm seeing that shows that this is true?

(Reply to this) (Parent)(Thread)


[info]onhava
2007-08-02 07:35 pm UTC (link)
Hrmm, you're right.... Looking at the one case I actually understand without thinking too hard, the 2-sphere, we compute the surface area as an integral of 2 pi times d(cos theta), or 2 pi times sin theta d(theta). So the right thing is to integrate d(theta), not dz... In other words, I was saying this one is the integral of sin(theta) d(cos(theta)) so I need to remove an extra factor of sin(theta). So what I want is z^2 (1-z^2)^((N-3)/2) in the first integral, and the same thing without z^2 in the second.

So, it's just 1/N, not 1/(N+2). Unless there's some further subtlety in the right integration measure in higher dimensions. I don't think there is though.

(Reply to this) (Parent)(Thread)


[info]onhava
2007-08-02 08:56 pm UTC (link)
Ugh, I keep screwing up. Let me try again: I'm removing one power of *sine*, not of *sine^2*, so that should be neither N-1 nor N-3 in the exponent but N-2, and the answer is 1/(N+1).

In other words, what [info]mmcirvin said somewhere above. But definitely O(1/N), even if I'm still wrong.

(Reply to this) (Parent)


[info]mmcirvin
2007-08-02 08:11 pm UTC (link)
Theta is the polar angle, goes from zero to pi. Sin theta is positive over that range.

(Reply to this) (Parent)(Thread)


[info]pbrane
2007-08-02 09:29 pm UTC (link)
ah, damn you and your "theta is the polar angle" ways. I was always in the phi camp for that (since that way theta can be the same angle in both 2 in 3 dimensions), and ya gots me confused!

Thanks for your help though. 1/N scaling is something I like to see. Although now that I think about it, I did the cube wrong - that case goes like O(1/sqrt(N)), not O(log(N)/N)... and that's a different scaling entirely... hmmm...

(Reply to this) (Parent)


(16 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…