Jump to content

Wikipedia:Reference desk/Archives/Mathematics/2008 March 13

From Wikipedia, the free encyclopedia
Mathematics desk
< March 12 << Feb | March | Apr >> March 14 >
Welcome to the Wikipedia Mathematics Reference Desk 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 on one of the current reference desk pages.


March 13

[edit]

Generating random numbers

[edit]

How would I generate random numbers with a distribution matching Zipf's law? --Carnildo (talk) 04:18, 13 March 2008 (UTC)[reply]

Could you start with a probability distribution that is linear ie each value occurs equally often and scale that to the zipf distribution? Would you need help scaling the fnuction?
Can it be assumed that you already have a method of generating random numbers in general?87.102.8.240 (talk) 09:10, 13 March 2008 (UTC)[reply]
According to the classic version of Zipf's law, the number of occurrences of the word that has rank k in a large corpus of words is proportional to 1/k, which means it is of the form c/k for some large constant c. But actually the value of c depends on the size of the corpus, where c is the number of different words in the corpus, and the size n of the corpus is roughly n = c·log c. Therefore it makes more sense to generate a sequence of numbers for which each initial segment obeys Zipf's law.
In pseudocode:
Let z1, z2, ... be the sequence to be generated.
Set c to 1
For n from 1 to whatever:
Set ν to 1/((log c)+1)
Select one alternative from:
(A) with probability ν:
Set zn to c
Set c to c+1
(B) with probability 1 − ν:
Pick a random number uniformly from the range {1 ... (n−1)}
Set zn to zr
Obviously the beginning will have few different numbers, so you may want to discard a large initial part. It is then not actually necessary to store the segment to be discarded itself, as long as the number of occurrences of each value is kept track of. --Lambiam 09:58, 13 March 2008 (UTC)[reply]
The above is surely right - but looked a little mysterious to me - here's another version of 'psuedo-code' - in this case I don't explicitly normalise the probabilities but instead generate a sum "Total" of 1/k and find the position of a random number between 0 and "Total" ie the first 'word' is between 0 and 1/1, the second between 1/1 and 1/1+1/2 etc
For different functions simply change all instances of 1/value to the new thing eg 1/values I've marked these positions with a *


n=number of words
Total = Sum to n of 1/k * !ie 1/1+1/2+1/3 etc


LOOP 1
R=Total x RND() ! ie Generate a random number between 0 and Sum total called R {RND() is a random function between 0 and 1} !
Length=0
m=1 !a loop counter


LOOP 2
Length=Length+1/m *
if R<=Length then print/output "m"  ! m is the mth word ! : GOTO LOOP 1 !start again!
increase m by 1 : goto LOOP 2


Just added in case others found the first example a little confusing.. apologies to any offended by the GOTOS.. the !!'s are comments. not factorials!87.102.8.240 (talk) 10:57, 13 March 2008 (UTC)[reply]
A counting variable can be added so that the program would stop after a certain number of random values had been produced. Would suggest adding this inside LOOP 1 eg Count=Count+1:If Count=10000 then END/STOP>87.102.8.240 (talk) 11:03, 13 March 2008 (UTC)[reply]
Note - what I've done here shares some similarities with Arithmetic coding or Entropy encoding - at least in small part.87.102.8.240 (talk) 11:15, 13 March 2008 (UTC)[reply]
(it could be extended to non-zipf distributions that have finite states from a single event, also the above could be speeded up slightly computer wise if that was neccessary - ask if you want further details on these.)83.100.138.116 (talk) 16:28, 13 March 2008 (UTC)[reply]

Financial calculator question

[edit]

I have a financial calculator question. I have the APY for a Certificate of Deposit; I am looking for a calculation that will give me its dividend rate if the dividends are paid Quarterly or if they are paid monthly.

For example, for a 12 month Certificate the APY is 3.25% what is the calculation to find out what the dividends are? —Preceding unsigned comment added by 207.109.247.177 (talk) 17:58, 13 March 2008 (UTC)[reply]

Comment: The poster is referring to the annual percentage yield. Pallida  Mors 19:16, 13 March 2008 (UTC)[reply]
Different institutions may use different definitions of the Annual Percentage Yield, which may be different from the effective rate, the Annual percentage rate, because certain costs have not been accounted for yet. Assuming the formula in our article holds for the definition actually used, and assuming dividend rate may be equated with the nominal interest rate, then:
  • for monthly dividend rate (12 periods) you get over a year:
  • for quarterly dividend rate (4 periods) you get over a year:
Note the caveats. Your mileage may vary.  --Lambiam 19:18, 13 March 2008 (UTC)[reply]

PDE -> ODE

[edit]

Are there a set of "standard" methods one could try to use to transform a PDE in several variables to a set of coupled ODEs? —Preceding unsigned comment added by 12.196.44.226 (talk) 20:22, 13 March 2008 (UTC)[reply]

maybe separation of variables#Partial differential equations? --Spoon! (talk) 03:49, 14 March 2008 (UTC)[reply]

I need help with pi & circumference

[edit]

If you calculated the circumference of a circle the size of the known universe, requiring that the answer be accurate to within the radius of one proton, how many decimal places of pi would you need to use?

 A. Two million
 B. 39
 C. 48,000
 D. Six billion

Thanks in advance.207.69.140.24 (talk) 21:48, 13 March 2008 (UTC)[reply]

I seem to recall the answer is 39, though I don't remember why. Strad (talk) 21:56, 13 March 2008 (UTC)[reply]
Assuming you’re calculating it from the radius of the known universe I think you could find an upper bound by dividing the smallest distance in question (radius of a proton) by twice the largest distance in question (radius of the universe), and using pi with as many decimal places as this number: because then would be accurate to the radius of a proton when multiplied by twice the radius of the known universe. GromXXVII (talk) 22:11, 13 March 2008 (UTC)[reply]
[ec] According to Observable universe, its diameter is ly, so its circumference is ly or m. The radius of a proton is roughly m. The ratio is roughly , thus roughly 39 digits of π are required. But don't let anyone fool you into thinking that this means that more digits are not required for science and applications. -- Meni Rosenfeld (talk) 22:18, 13 March 2008 (UTC)[reply]

A question similar to this has been asked before. It was to find the circumference of the known universe to the accuracy of a planck length.

And the answer is that 62 digits of Pi was required, preferably 64 digits. I'll see if I can dig up a link.

http://en.wikipedia.org/wiki/Wikipedia:Reference_desk_archive/Science/2006_September_27#How_many_digits_of_pi_for_the_known_universe.3F

202.168.50.40 (talk) 00:08, 14 March 2008 (UTC)[reply]

We have no data to base the calculation on, so knowing the decimal expansion of π to many places is not going to help. Even if we knew the radius of the observable universe to within the radius of a proton, and we could halt the universe so that it stopped expanding while we are doing the calculation, we don't even know if the universe is flat.  --Lambiam 08:40, 14 March 2008 (UTC)[reply]
Well, the question didn't ask about the circumference of the observable universe, but rather of a circle the size of it. I guess what this means exactly is open to interpretation, but I think "fix a number of arbitrarily high precision and magnitude on the same order as the observable universe, and use it as a radius" is a valid one. -- Meni Rosenfeld (talk) 10:38, 14 March 2008 (UTC)[reply]
See Cosmic View: The Universe in 40 Jumps by Kees Boeke - a classic. Gandalf61 (talk) 14:21, 14 March 2008 (UTC)[reply]