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