Showing posts with label TI 84 Plus. Show all posts
Showing posts with label TI 84 Plus. Show all posts

Friday, July 5, 2019

The 1000th Post: HP Prime and TI-84 Plus: Log-Normal Distribution

The 1000th Post:  HP Prime and TI-84 Plus: Log-Normal Distribution



This is a landmark for this blog, this is post 1,000.  One Thousand.   And it is still fun.  I thank you all for your support - very grateful.

On to the next 1,000!

Introduction - Log-Normal Distribution

The programs presented in this blog will calculate the PDF (probability density function) and the CDF (cumulative density function).  The CDF calculates the lower tail probability.   The formulas are:

PDF:   e^(-(ln x - μ)^2 / (2 * σ^2) )

CDF:  1/2 + 1/2 * erf( (ln x - μ) / (σ * √2) )

where:  x = point on the distribution, μ = mean (default 0), σ = deviation (default 1)

Log-Normal Distribution

HP Prime Program LOGNORM_PDF

EXPORT LOGNORM_PDF(μ,s,x)
BEGIN
// log normal pdf
// μ, σ, x 
RETURN (x*s*√(2*π))^(-1)*
e^(−(LN(x)-μ)^2/(2*s^2));
END;

TI-84 Plus Program LOGNRMPD

Input "MEAN: ",M
Input "STDDEV: ",S
Input "X: ",X
(X*S*√(2*π))^-1*e^(­(ln(X)-M)²/(2*S^2))→P
Disp "PDF=",P

Example 1:
Mean = 0, Standard Deviation = 1, X = 2.5
PDF = 0.1048710669

HP Prime Program LOGNORM_CDF

EXPORT LOGNORM_CDF(μ,s,x)
BEGIN
// log normal cdf - lower tail
// μ, σ, x
RETURN .5+
.5*CAS.erf((LN(x)-μ)/(s*√2));
END;

TI-84 Plus Program LOGNRMCD

Input "MEAN: ",M
Input "STDDEV: ",S
Input "X: ",X
"ERF"
(ln(X)-M)/(S*√(2))→Z
2/√(π)*fnInt(e^(­T^2),T,0,Z)→E
"CDF"
.5+.5*E→C
Disp "CDF: ",C

Example 2:
Mean = 0, Standard Deviation = 1, X = 2.5
PDF = 0.8202427861

Thank you, here's to the next 1,000 posts....

Source:

"Log-normal distribution" Wikipedia Last edited May 15, 2019.  https://en.wikipedia.org/wiki/Log-normal_distribution  Retrieved May 25, 2019


Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, November 17, 2018

TI-84+ and Casio (fx-CG 50) Micropython: Simplifying Nested Radicals

TI-84+ and Casio (fx-CG 50) Micropython: Simplifying Nested Radicals

Introduction 

The following program will simplifying the following expression:

√(x + y) = √a + √b

The input is x and y, with output a and b.  The following conditions are implied:  x > y and x > 0.

To see the derivation of simplification and examples, please check out this blog entry:

https://edspi31415.blogspot.com/2018/11/simplifying-nested-radicals.html

TI 84 Plus Program:  DENEST

"EWS 2018-11-12"
Disp "√(X+Y)=√(A)+√(B)","X>Y","X>0"
Prompt X,Y
X/2+1/2*√(X^2-Y^2)→A
X/2-1/2*√(X^2-Y^2) →B
√(A)→Z
round(Z,9)→Z
Disp " "

If Y<0 font="">

Then
If fPart(Z)=0
Then 
Disp √(A),"- √(",B,")"
Else 
Disp "√(",A,")- √(",B,")"
End

Else
If fPart(Z)=0
Then 
Disp √(A),"+ √(",B,")"
Else 
Disp "√(",A,")+ √(",B,")"
End

End

Casio Micropython (fx-CG 50) Script denest.py

Input is the form of:

√(x1 * √x2 + y1 * √y2) = √a + √b

import math
print("sqrt(x+y)=")
print("sqrt(a)+sqrt(b)")
print("x>y","x>0")

print(" ")
print("x1*sqrt(x2)")
x1=float(input("x1:"))
x2=float(input("x2:"))
x=x1*math.sqrt(x2)

print(" ")
print("y1*sqrt(y2)")
y1=float(input("y1:"))
y2=float(input("y2:"))
y=y1*math.sqrt(y2)

a=x/2+math.sqrt(x**2-y**2)
b=x/2-math.sqrt(x**2-y**2)
z=math.sqrt(a)
z=round(z,10)
a=round(a,10)
b=round(b,10)

if y<0: font="">
  if z-int(z)==0:
    print(z,"-sqrt(")
    print(b,"?")
  else:
    print("sqrt(",a)
    print("-sqrt(")
    print(b,")")
else:
  if z-int(z)==0:
    print(z,"+sqrt(")
    print(b,")")
  else:
    print("sqrt(",a)
    print("+sqrt(")
    print(b,")")


Source:

Michael J. Wester, Editor.  Computer Algebra Systems: A Practical Guide John Wiley & Sons: Chichester 1999.  ISBN 978-0-471-983538

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Basic vs. Python: Circle Inscribed in Circle [HP 71B, Casio fx-CG 100]

Basic vs. Python: Circle Inscribed in Circle Calculators Used: Basic: HP 71B Python: Casio fx-CG 100 Introduction ...