

No, that's not what is meant by "inverse". It's the inverse distribution function he's looking for.
I'm the ocean. I'm a giant undertow.





You should check out http://www.google.com.au/codesearch[^] first when you have a well known function that you want, I had a quick check and there seems to be implementations there.
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."





I Didn't see any implementations there. If u have seen any then plz provide some link.





There are multiple implementations there  it is really in your interest to learn how to search for them. I bet you simply typed in "NORMSINV" and just got lots of references to uses of the function, gave up and came back here. You have to be a little creative and try to make the search engine find function definitions. I went to the same page and with my next search came up with several implementations.
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."





The inverse CDF of the normal distribution doesn't have an analytical form. You can find an approximation here[^].
The other place to look is in the online version of Numerical Recipes[^]. They have an algorithm for the inverse normal CDF.
You can also use the following taken from here[^].
What is a good approximation to the inverse of the
cumulative normal distribution function? Mathematically we can
write this as: Find X such that Q(X) = p for any 0 < p < 1.
(Note: this computes an upper tail probability.) Again, it is
not possible to write this as a closed form expression, so we
resort to approximations. Because of the symmetry of the normal distribution,
we need only consider 0 < p < 0.5. If you
have p > 0.5, then apply the algorithm below to q = 1p,
and then negate the value for X obtained. (This approximation
is also from Abramowitz and Stegun.)
t = sqrt[ ln(1/p^2) ]
c_0 + c_1*t + c_2*t^2
X = t  
1 + d_1*t + d_2*t^2 + d_3*t^3
c_0 = 2.515517
c_1 = 0.802853
c_2 = 0.010328
d_1 = 1.432788
d_2 = 0.189269
d_3 = 0.001308
See Abramowitz and Stegun; Press, et al.
You should Google a little harder instead of always asking here. These algorithms were worked out a long time ago and have been available for a long time.
I'm the ocean. I'm a giant undertow.





73Zeppelin wrote: You should Google a little harder instead of always asking here
I think it is more of a case of sheer laziness. He's asking about the FDIST function now, and I pointed him to Wolfram's Mathworld.
"The clue train passed his station without stopping."  John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks"  Pete O'Hanlon





How to find NORMSDIST function of ms excel.It Returns the standard normal cumulative distribution function. The distribution has a mean of 0 (zero) and a standard deviation of one. Use this function in place of a table of standard normal curve areas.
Syntax
NORMSDIST(z)
Z is the value for which you want the distribution.
Thanks





drinking beer is a wonderful experience.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.  Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.  Iain Clarke
[My articles]






Don't you agree on beer drinking statement?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.  Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.  Iain Clarke
[My articles]





No
If u know the answer plz tell me..





How can I answer if there is NO question?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.  Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.  Iain Clarke
[My articles]





i want to make function to calculate Normsdist like this:
Public Function calculateNormsdist(ByVal z As Single) As Single
and it will give the answer can u implement it??





sumit7034 wrote: can u implement it??
yes
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."





sumit7034 wrote: can u implement it??
cp9876 wrote: yes
I was pretty sure about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.  Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.  Iain Clarke
[My articles]





plz implement it





sumit7034 wrote: plz implement it
Why him? Can't you?
"The clue train passed his station without stopping."  John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks"  Pete O'Hanlon





sumit7034 wrote: i want to make function
sumit7034 wrote: can u implement it?
The two statements above are in contraddiction (unless sumit7034 and cpallini are the same person ).
BTW Now your question is clear, but is too broad and a bit lazy: what have you done so far? What are your troubles about? I mean, numerically computing the cumulative of the normal distribution isn't such a daunting task, I suppose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.  Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.  Iain Clarke
[My articles]





Implementation 1:
<pre>double CNDF(double x)
{
int neg = (x < 0);
if ( neg )
x *= 1;
double k(1/(1+0.2316419*x));
double y=((((1.330274429*k1.821255978)*k+1.781477937)*k0.356563782)*k+0.319381530)*k;
y = 1.0  0.398942280401*exp(0.5*x*x)*y;
return (1neg)*y + neg*(1y);
}</pre>
Implementation 2
<pre>double CumNorm(double x)
{
if (x > 6.0)
return 1.0;
if (x < 6.0)
return 0.0;
double b1 = 0.31938153;
double b2 = 0.356563782;
double b3 = 1.781477937;
double b4 = 1.821255978;
double b5 = 1.330274429;
double p = 0.2316419;
double c2 = 0.3989423;
double a = fabs(x);
double t = 1.0 / (1.0 + a * p);
double b = c2*exp((x)*(x/2.0));
double n = ((((b5*t+b4)*t+b3)*t+b2)*t+b1)*t;
n = 1.0b*n;
if ( x < 0.0 )
n = 1.0  n;
return n;
}</pre>
I'm the ocean. I'm a giant undertow.





Wow, no iterations?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.  Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.  Iain Clarke
[My articles]





No, none.
I'm the ocean. I'm a giant undertow.





Thanks my proble is solved






I'm a desperate Geocacher (www.geocaching.com) trying to solve a difficult puzzle.
I see discussions in this forum about the rightmost nonzero digit of 1000000! is 4.
Can anybody figure out the six rightmost nonzero digits of one million factorial?
As an incentive, I'll send $20 (via PayPal) to the first person who posts the correct answer.
Thanks! Rod





The last six nonzero digits of 1,000,000! are 412544. Please, keep your money.
I wrote this code to calculate your answer:
using System;
class Program
{
const ulong Target = 1000000; const ulong RoundOff = 10000000000;
static void Main(string[] args)
{
ulong factorial = 1;
for (ulong n = 1; n <= Target; n++)
{
factorial *= n;
while (factorial % 10 == 0)
{
factorial /= 10;
}
factorial %= RoundOff;
}
Console.WriteLine("{0}! (truncated) = {1}", Target, factorial);
}
}
Why it works:
When multiplying numbers, the trailing zeros at the end will not change the outcome... so I threw those out.
Also, if you are only interested in the least significant digits, then the uppermost digits will not have an effect on the outcome of the lower digits... so I threw those out.
With all the rounding, I didn't have to worry about overflow so I was able to calculate the "truncated factorials" of very large numbers iteratively.
Enjoy,
Robert C. Cartaino
modified on Wednesday, July 2, 2008 1:26 PM





Way cool! Thank you very much! Rod





One thing I forgot to mention in the source code; I rounded off to a few more digits than required because the top digit or two might be wrong because of the rounding. In other words, if you need six digits, calculate for eight. The sixdigit answer I gave above is accurate.





Good Day,
It's me again. This question is one of the questions in ACM ICPC 2006  Philippines.
Basically, you need to express a large number as a product of its Primes.
For example: 120 = 2x2x2x3x5 (or 2^3x3^1x5^1)
I'm lost on how to begin to tackle this problem. Please advice.
Thank you.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





Think of how you would do it on paper or using a calculator and generalise...
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."





That is my problem, I don't even know how to do it on paper. I have tried, believe me.
Can you just give me some reading material that will at least help me?
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





Ian Uy wrote: I'm lost on how to begin to tackle this problem. Please advice.
As a college student, you really should be able to do this. It's basic math.
What you will want to search for is called "prime factorization." The easiesttounderstand technique is called "trial division."
On paper, you start by writing down your large number (let's call it 'n'). Then try to think of another number which divides evenly into n without any remainder. That number is a factor of n. It's easiest to start with small numbers.
In your example, what number divides evenly into 120 ? How about 2 ? Yes, 120/2=60 . So write down 2 and 60 (those are factors of 120 , but not necessarily prime).
Then try to factor each number you wrote down (the 2 and the 60 ). Are there any numbers (other than 1) that divide into 2 evenly? No, so 2 is a "prime factor" of 120 (i.e. 2 cannot be divided any further).
How about the 60 ? 60/2=30 . So, there is another 2 that is a prime factor of 120 . So far we have the factors of 120=2,2,30 . Now factor the 30 and keep going.
Keep going until you run out of numbers that can be divided evenly. Those will be your prime factors.
120 factored = 2,60 (2 is prime) 60 factored = 2,30 (2 is prime) 30 factored = 2,15 (2 is prime) 15 factored = 3,5 (both 3 and 5 are prime) Done.
The prime factors of 120 are (from the parentheses above) 2,2,2,3,5 .
Now try writing that in code and see what you come up with. You can use this Table of Prime Factors[^] to check your answers.





Thank you. I have always been really stupid in basic math.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





Ian Uy wrote: I have always been really stupid in basic math.
If you are stupid in math i strongly advice you to change you major because math is core for Computer sceince.
The Developer  CEH





Thanks for your reply. I have successfully translated it into C++.
int main()
{
int InputCase;
cin >> InputCase;
for(int i=2;i<=InputCase;i++)
{
if(InputCase%i==0)
{
cout << i;
InputCase/=i;
i;
}
}
return 0;
}
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





Are you sure this works? There are cases where i is not a prime...
"The clue train passed his station without stopping."  John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks"  Pete O'Hanlon





Yup, for some reason it did threw the right answers.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





That is interesting.
"The clue train passed his station without stopping."  John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks"  Pete O'Hanlon





It works, but it's inefficient.
/ravi





Ian Uy wrote: Yup, for some reason it did threw the right answers.
I think if you're aiming for the ACM ICPC then you should try to understand why it gives the correct answers (and at first glance it looks as if it should). The fact that i may not be prime actually doesn't matter (well except for efficiency concerns).
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."





Hi,
one remark: you should replace the if(){} construct by a while(){} and drop the i; that way your code is more readable, and you can now more easily reduce the divisor candidates (say to only 2 and odd numbers, or just primes, or whatever else has already been suggested).





Robert.C.Cartaino wrote: As a college student, you really should be able to do this. It's basic math.
To be fair, my bet is 99% of college students don't know (or care) how to do this, along with 99% of the rest of the world.
I'm about to finish up my second engineering degree, and prime numbers have not been brought up once during the 5 years i've been here.





MarkBrock wrote: my bet is 99% of college students don't know (or care) how to do this, along with 99% of the rest of the world.
I agree. Maybe a bit more than 99%, like 99.9999%
"The clue train passed his station without stopping."  John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks"  Pete O'Hanlon





MarkBrock wrote: To be fair, my bet is 99% of college students don't know (or care) how to do this, along with 99% of the rest of the world.
You must have been taught how at junior school, though
I know, since my son has this in his Math book.





ChandraRam wrote: You must have been taught how at junior school, though
Yeah, I was.
Sit down and watch the TV show "Are you smarter than a 5th grader". Unless you've got better memory than an elephant, I bet you can't answer most of the questions .





You do not need to divide by all numbers, only by primes. If the number is evenly divided by a prime, then keep dividing by that prime until the result leaves a remainder, then go to the next prime. There exists (google primes) a site on which there is a list of the primes for the first million numbers, the second million numbers ... to the first 15 million numbers.
Dave Augustine.





Member 4194593 wrote: You do not need to divide by all numbers, only by primes.
... and, if we are optimizing, your forloop does not need to run all the way up to InputCase . You only need to check for divisibility of numbers up to the square root of InputCase .





I see. I'll apply both suggestions.
That's why its so slow at 20!.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.





Ian Uy wrote: That's why its so slow at 20!.
There are easier ways of factorizing 20!
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."





A possible solution would be as follows:
void prime_factors(unsigned int n, std::deque<std::pair<unsigned int,unsigned int>>& factor_list)
{
factor_list.clear();
unsigned int upper_bound = ::floor(std::sqrt(n));
unsigned int i = 2;
while(i <= upper_bound)
{
std::pair<unsigned int, unsigned int> current_factor(i,0);
while(0 == (n % i))
{
n /= i;
++current_factor.second;
}
if (current_factor.second > 0)
{
factor_list.push_back(current_factor);
}
++i;
}
}
The primefactors will be in the deque, the first of each element is the factor and the second is the recurrence count of the factor.
[updated]





[edit] since Arash has completely changed the code in his previous post, this appears somewhat out of context [/edit]
I think this is an example of misguided optimization. Whilst Ian Uy's example looks inefficient
int main()
{
int InputCase;
cin >> InputCase;
for(int i=2;i<=InputCase;i++)
{
if(InputCase%i==0)
{
cout << i;
InputCase/=i;
i;
}
}
return 0;
}
all he is doing each iteration is testing
if(InputCase%i==0)
In order to avoid these "unnecessary" tests, you are testing each n as
if (n % 2 == 0) n++;
while(!is_prime(n)) { ++n; }
The function is_prime(n) will involve much more overhead than the original code, and it doesn't matter that 'i' may not be prime.
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
modified on Saturday, October 18, 2008 11:35 PM



