Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I need to use the Probability Function on a set of values. I am okay with understanding the math, but i don't quite know how to convert that stuff to code.

basically i need the integral of f(x) from a to b where f(x) is the curve of the random function. So how do i calculate it ? I mean if f(x) was (x+5x) and a=5 b=46, how would you calculate the integral ?

I thought people on this site might have done these things before, so i asked this question here.

share|improve this question
2  
Is $x+5x$ different from $6x$, please fix the typo, may be one of them has an exponent! –  user21436 Jan 13 '12 at 9:35
    
You can do an Ito integral. By using your pdf you will have to compute $\lim_{n\rightarrow\infty}\langle\left[\sum_{i=0}^{n-1}f(\xi_i)\right]^2\rangle$‌​. –  Jon Jan 13 '12 at 9:50
    
@KannappanSampath is meant x squared plus five x but its just an example anyway .. –  Wildling Jan 13 '12 at 10:28

1 Answer 1

up vote 3 down vote accepted

In general one should distinguish three steps for such a task:

a) choosing a discrete approximation to the problem that can be handled by a machine that has a finite memory only. Such algorithms are explained in the literature of numerical mathematics. In this case (numerical approximation to an integral) you could look up e.g. Gauss quadrature or - somewhat more elementary - the Simpson rule.

c) a concrete implementation in a programming language that takes in parameters and spits out numbers. You can find some implementations in C++ in the book Numerical Recipes (people here may crucify me for recommending this book, because there are many over-simplifications and misunderstandings in it. But I think it is still a very good introduction to the basic ideas and algorithms, although professionals need something else, for sure.)

What happended to b) ? Well, step b) would be a description of a concrete algorithm for the approximation from step a) in a platform-agnostic way (on a higher level of abstraction that a concrete implementation), so that one can implement the algorithm in whatever programming language that is appropriate (including Matlab, Sage, Mathematica). This is usually neglected however in the literature, so that you will have to do it yourself. But a book like "Numerical Recipes" should be a good start.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.