Ask Your Question
0

Problem recreating example of normal distribution from TI-Nspire [closed]

asked 2017-04-27 12:13:59 -0500

Ross1856 gravatar image

I have to recreate this formula for calculating normal distribution in Sage:

http ://ntaj.dreamhosters.com/ti.jpg

The picture is from TI-Nspire CAS.

What I'm doing is:

sage: f=1/(0.1sqrt(2pi)) * e^((-1/2)*((x-4)/0.1))^2

sage: float(integral(f, 3.9, 4.1))

0.8696735925295498

I can't get the expected result 0.682689 that Nspire gives. Can anyone see why?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Ross1856
close date 2017-04-28 04:24:30.118994

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-04-27 15:04:14 -0500

eric_g gravatar image

You did not get the expected result because the last ^2 is ill placed; it should be inside the parentheses:

sage: f = 1/(0.1*sqrt(2*pi)) * e^((-1/2)*((x-4)/0.1)^2)

Then

sage: numerical_integral(f, 3.9, 4.1)
(0.6826894921370853, 7.579375928402468e-15)

(the second number is an evaluation of the numerical error).

edit flag offensive delete link more
0

answered 2017-04-27 14:58:16 -0500

dan_fulea gravatar image

Pari/gp delivers:

? s = 0.1;

? intnum( x=3.9, 4.1, exp( -(x-4)^2/2/s^2 ) / sqrt(2*Pi*s^2) )                                                                
%2 = 0.6826894921370858971704650911

We can do the same in sage, i.e. call gp:

sage: gp( "intnum( x=3.9, 4.1, exp( -(x-4)^2/2/%s^2 ) / sqrt(2*Pi)/%s)" % ( 0.1, 0.1 ) )
0.6826894921370858971704650911

Or call the numerical integral from sage:

sage: integral_numerical( lambda x :    exp( -(x-4)^2/2/0.1^2 ) / sqrt(2*pi)/0.1, 3.9, 4.1 )
(0.6826894921370853, 7.579375928402468e-15)

which computes the approximative value 0.6826894921370853 with an error less than $7,6\cdot 10^{-15}$, as given in the second argument.

edit flag offensive delete link more

Comments

I'll have to read up on that. Thank you for the reference.

Ross1856 gravatar imageRoss1856 ( 2017-04-28 04:28:03 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-27 12:13:59 -0500

Seen: 33 times

Last updated: Apr 27