line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Gauss::XS; |
2
|
1
|
|
|
1
|
|
15722
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
84
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw( Exporter ); |
9
|
|
|
|
|
|
|
our %EXPORT_TAGS = ('all' => [qw( pdf cdf inv_cdf )]); |
10
|
|
|
|
|
|
|
Exporter::export_ok_tags('all'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require XSLoader; |
13
|
|
|
|
|
|
|
XSLoader::load('Math::Gauss::XS', $VERSION); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Math::Gauss::XS - Gaussian distribution function and its inverse, fast XS version |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
0.01 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 STATUS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=begin HTML |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=end HTML |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Math::Gauss::XS ':all'; |
36
|
|
|
|
|
|
|
my ($p, $c, $z, $x, $m, $s); # intialize them |
37
|
|
|
|
|
|
|
$p = pdf( $z ); |
38
|
|
|
|
|
|
|
$p = pdf( $x, $m, $s ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$c = cdf( $z ); |
41
|
|
|
|
|
|
|
$c = cdf( $x, $m, $s ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$z = inv_cdf( $z ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This module just rewrites the L module in XS. The precision and |
48
|
|
|
|
|
|
|
exported function remain the same as in the original. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The benchmark results are |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Benchmark: timing 30000000 iterations of pp/pdf, xs/pdf... |
53
|
|
|
|
|
|
|
pp/pdf: 15 wallclock secs (14.99 usr + 0.00 sys = 14.99 CPU) @ 2001334.22/s (n=30000000) |
54
|
|
|
|
|
|
|
xs/pdf: 2 wallclock secs ( 2.16 usr + 0.00 sys = 2.16 CPU) @ 13888888.89/s (n=30000000) |
55
|
|
|
|
|
|
|
Benchmark: timing 30000000 iterations of pp/cdf, xs/cdf... |
56
|
|
|
|
|
|
|
pp/cdf: 40 wallclock secs (38.93 usr + 0.00 sys = 38.93 CPU) @ 770613.92/s (n=30000000) |
57
|
|
|
|
|
|
|
xs/cdf: 2 wallclock secs ( 2.22 usr + 0.00 sys = 2.22 CPU) @ 13513513.51/s (n=30000000) |
58
|
|
|
|
|
|
|
Benchmark: timing 30000000 iterations of pp/inv_cdf, xs/inv_cdf... |
59
|
|
|
|
|
|
|
pp/inv_cdf: 15 wallclock secs (16.02 usr + 0.00 sys = 16.02 CPU) @ 1872659.18/s (n=30000000) |
60
|
|
|
|
|
|
|
xs/inv_cdf: 2 wallclock secs ( 2.18 usr + 0.00 sys = 2.18 CPU) @ 13761467.89/s (n=30000000) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=for Pod::Coverage cdf inv_cdf pdf |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SOURCE CODE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
binary.com, C<< >> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 BUGS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
76
|
|
|
|
|
|
|
L. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |