How To Calculate Approximate Expectation Of Function Of A Binomial Random Variable?

Is there any function to calculate how many times a number (0-9) has been repeated up to the nth decimal number of pi?

  • We can calculate the value of pi up to certain decimal number,assume it to be n.I'm asking if there is any function to calculate how many times 1 or 2 or 3 or ....9 has been repeated within this n digits..!! I'm only taking into consideration the single digit numbers..!!!

  • Answer:

    I think the bigger problem programmers face is getting the exact value of pi .... double in Java has a precision of upto only 15 decimal digits... Unfortunately for us Math.pi returns a type double value so it will not give u the exact value of pi after 15 digits... What you will have to use is BigDecimal....Something like MathContext mc=new MathContext(n); BigDecimal bd=new BigDecimal(2,mc); This will set the precision level and then you can use the machin's formula or the arccot computation to get the exact value... Once you do get the exact value of pi I think the method of setting an array counting the numbers is quite appropriate for solving the problem Of course you should avoid any kind of recursion as it will more or less lead to a stack overflow... Main problem lies In the fact that there is no recurrence in pi...that's what makes it difficult.. PS:- sorry for any typos as I am typing from my cell... :P

Sagar Wahal at Quora Visit the source

Was this solution helpful to you?

Other answers

I think a simple C program would do the trick. 1. Initialise a array of size 10 which would store the number of times each digit has occured in the sequence.[0 0 0 0 0 0 0 0 0 0 0] 2. From rightmost end, get individual digits using modulus command. Remember to remove the decimal and take the number as a sequence of digits, meaning have 3.141 as 3141 by multiplying it by 1000 (number of decimal places) 3. After you get a number, increment the n+1th location of the array by 1. if you get 3, increment the 4th position. Now the array will be [0 0 0 1 0 0 0 0 0 0 0] 4. Same way increment till the end. If you had taken pi as 3.14159265359, then your array will be [0 2 1 2 1 3 1 0 0 2] Why do you need a mathematical function for ?

Anonymous

I don't know for sure but look for pi in modular arthimetic and any connection if there is then u can manipulate and by mod10 and mod100 u may actually fine the digits

Durga Dinesh

no. there is no pattern as such.

Maanav Doshi

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.