« blib/lib/Math/Business/BlackScholes/Binaries/Greeks.pm
↑ Summary
lib/Math/Business/BlackScholes/Binaries/Greeks/Math.pm »
| 1 | package Math::Business::BlackScholes::Binaries::Greeks::Math; | ||
| 2 | use strict; use warnings; | ||
| 3 | |||
| 4 | our $VERSION = '0.04'; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | BOM::Utility::Math::Routines | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | Misc math routines. | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | use base qw( Exporter ); | ||
| 17 | our @EXPORT_OK = qw( ddgauss dgauss ); | ||
| 18 | |||
| 19 | =head2 dgauss | ||
| 20 | |||
| 21 | normal density | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | use constant PI => 4 * atan2(1, 1); | ||
| 26 | |||
| 27 | sub dgauss { | ||
| 28 | my $x = shift; | ||
| 29 | |||
| 30 | return exp(-1 * $x * $x / 2) / (2 * PI)**0.5; | ||
| 31 | } | ||
| 32 | |||
| 33 | =head2 ddgauss | ||
| 34 | |||
| 35 | dnormal density | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | sub ddgauss { | ||
| 40 | my $x = shift; | ||
| 41 | |||
| 42 | return -1 * $x * dgauss($x); | ||
| 43 | } | ||
| 44 | |||
| 45 | 1; |