9999
100100=for usage
101101
102- perldl > p $data
102+ pdl > p $data
103103 [
104104 [ 5 BAD 2 BAD]
105105 [ 7 3 7 BAD]
106106 ]
107107
108- perldl > p $data->fill_m
108+ pdl > p $data->fill_m
109109 [
110110 [ 5 3.5 2 3.5]
111111 [ 7 3 7 5.66667]
@@ -148,13 +148,13 @@ observations from the same variable.
148148
149149=for usage
150150
151- perldl > p $data
151+ pdl > p $data
152152 [
153153 [ 5 BAD 2 BAD]
154154 [ 7 3 7 BAD]
155155 ]
156156
157- perldl > p $data->fill_rand
157+ pdl > p $data->fill_rand
158158
159159 [
160160 [5 2 2 5]
@@ -383,20 +383,16 @@ Usage:
383383 # DV, 2 person's ratings for top-10 box office movies
384384 # ascending sorted by box office numbers
385385
386- perldl> p $y = qsort ceil( random(10, 2)*5 )
387- [
388- [1 1 2 4 4 4 4 5 5 5]
389- [1 2 2 2 3 3 3 3 5 5]
390- ]
386+ pdl> p $y = pdl '1 1 2 4 4 4 4 5 5 5; 1 2 2 2 3 3 3 3 5 5'
391387
392388 # model with 2 IVs, a linear and a quadratic trend component
393389
394- perldl > $x = cat sequence(10), sequence(10)**2
390+ pdl > $x = cat sequence(10), sequence(10)**2
395391
396392 # suppose our novice modeler thinks this creates 3 different models
397393 # for predicting movie ratings
398394
399- perldl > p $x = cat $x, $x * 2, $x * 3
395+ pdl > p $x = cat $x, $x * 2, $x * 3
400396 [
401397 [
402398 [ 0 1 2 3 4 5 6 7 8 9]
@@ -412,14 +408,14 @@ Usage:
412408 ]
413409 ]
414410
415- perldl > p $x->info
411+ pdl > p $x->info
416412 PDL: Double D [10,2,3]
417413
418414 # insert a dummy dim between IV and the dim (model) to be broadcasted
419415
420- perldl > %m = $y->ols_t( $x->dummy(2) )
416+ pdl > %m = $y->ols_t( $x->dummy(2) )
421417
422- perldl > p "$_\t$m{$_}\n" for sort keys %m
418+ pdl > p "$_\t@{[ $m{$_} =~ /^\n*(.*?)\n*\z/s] }\n" for sort keys %m
423419
424420 # 2 persons' ratings, each fitted with 3 "different" models
425421
@@ -613,20 +609,20 @@ Usage:
613609 # suppose these are two persons' ratings for top 10 box office movies
614610 # ascending sorted by box office
615611
616- perldl > p $y = qsort ceil(random(10, 2) * 5)
612+ pdl > p $y = qsort ceil(random(10, 2) * 5)
617613 [
618614 [1 1 2 2 2 3 4 4 4 4]
619615 [1 2 2 3 3 3 4 4 5 5]
620616 ]
621617
622618 # first IV is a simple linear trend
623619
624- perldl > p $x1 = sequence 10
620+ pdl > p $x1 = sequence 10
625621 [0 1 2 3 4 5 6 7 8 9]
626622
627623 # the modeler wonders if adding a quadratic trend improves the fit
628624
629- perldl > p $x2 = sequence(10) ** 2
625+ pdl > p $x2 = sequence(10) ** 2
630626 [0 1 4 9 16 25 36 49 64 81]
631627
632628 # two difference models are given in two pdls
@@ -635,9 +631,9 @@ Usage:
635631 # the 2nd model includes linear and quadratic trends
636632 # when necessary use dummy dim so both models have the same ndims
637633
638- perldl > %c = $y->r2_change( $x1->dummy(1), cat($x1, $x2) )
634+ pdl > %c = $y->r2_change( $x1->dummy(1), cat($x1, $x2) )
639635
640- perldl > p "$_\t$c{$_}\n" for sort keys %c
636+ pdl > p "$_\t$c{$_}\n" for sort keys %c
641637 # person 1 person 2
642638 F_change [0.72164948 0.071283096]
643639 # df same for both persons
@@ -711,21 +707,21 @@ Usage:
711707
712708 # suppose this is ratings for 12 apples
713709
714- perldl > p $y = qsort ceil( random(12)*5 )
710+ pdl > p $y = qsort ceil( random(12)*5 )
715711 [1 1 2 2 2 3 3 4 4 4 5 5]
716712
717713 # IV for types of apple
718714
719- perldl > p $a = sequence(12) % 3 + 1
715+ pdl > p $a = sequence(12) % 3 + 1
720716 [1 2 3 1 2 3 1 2 3 1 2 3]
721717
722718 # IV for whether we baked the apple
723719
724- perldl > @b = qw( y y y y y y n n n n n n )
720+ pdl > @b = qw( y y y y y y n n n n n n )
725721
726- perldl > %m = $y->anova( $a, \@b, { IVNM=>['apple', 'bake'] } )
722+ pdl > %m = $y->anova( $a, \@b, { IVNM=>['apple', 'bake'] } )
727723
728- perldl > p "$_\t@{[$m{$_} =~ /^\n*(.*?)\n*\z/s]}\n" for sort keys %m
724+ pdl > p "$_\t@{[$m{$_} =~ /^\n*(.*?)\n*\z/s]}\n" for sort keys %m
729725 F 2.46666666666667
730726 F_df [5 6]
731727 F_p 0.151168719948632
@@ -1288,8 +1284,8 @@ Supports BAD value (missing or 'BAD' values result in the corresponding pdl elem
12881284
12891285=for usage
12901286
1291- perldl > @a = qw(a a a b b b c c c)
1292- perldl > p $a = dummy_code(\@a)
1287+ pdl > @a = qw(a a a b b b c c c)
1288+ pdl > p $a = dummy_code(\@a)
12931289 [
12941290 [1 1 1 0 0 0 0 0 0]
12951291 [0 0 0 1 1 1 0 0 0]
@@ -1358,8 +1354,8 @@ Supports BAD value (missing or 'BAD' values result in the corresponding pdl elem
13581354
13591355=for usage
13601356
1361- perldl > @a = qw( a a b b b c c )
1362- perldl > p $a = effect_code_w(\@a)
1357+ pdl > @a = qw( a a b b b c c )
1358+ pdl > p $a = effect_code_w(\@a)
13631359 [
13641360 [ 1 1 0 0 0 -1 -1]
13651361 [ 0 0 1 1 1 -1.5 -1.5]
@@ -1389,20 +1385,20 @@ pdl elements being marked as BAD).
13891385
13901386=for usage
13911387
1392- perldl > $a = sequence(6) > 2
1393- perldl > p $a = $a->effect_code
1388+ pdl > $a = sequence(6) > 2
1389+ pdl > p $a = $a->effect_code
13941390 [
13951391 [ 1 1 1 -1 -1 -1]
13961392 ]
13971393
1398- perldl > $b = pdl( qw( 0 1 2 0 1 2 ) )
1399- perldl > p $b = $b->effect_code
1394+ pdl > $b = pdl( qw( 0 1 2 0 1 2 ) )
1395+ pdl > p $b = $b->effect_code
14001396 [
14011397 [ 1 0 -1 1 0 -1]
14021398 [ 0 1 -1 0 1 -1]
14031399 ]
14041400
1405- perldl > p $ab = interaction_code( $a, $b )
1401+ pdl > p $ab = interaction_code( $a, $b )
14061402 [
14071403 [ 1 0 -1 -1 -0 1]
14081404 [ 0 1 -1 -0 -1 1]
@@ -1450,20 +1446,20 @@ Usage:
14501446 # suppose this is a person's ratings for top 10 box office movies
14511447 # ascending sorted by box office
14521448
1453- perldl > p $y = qsort ceil( random(10) * 5 )
1449+ pdl > p $y = qsort ceil( random(10) * 5 )
14541450 [1 1 2 2 2 2 4 4 5 5]
14551451
14561452 # construct IV with linear and quadratic component
14571453
1458- perldl > p $x = cat sequence(10), sequence(10)**2
1454+ pdl > p $x = cat sequence(10), sequence(10)**2
14591455 [
14601456 [ 0 1 2 3 4 5 6 7 8 9]
14611457 [ 0 1 4 9 16 25 36 49 64 81]
14621458 ]
14631459
1464- perldl > %m = $y->ols( $x )
1460+ pdl > %m = $y->ols( $x )
14651461
1466- perldl > p "$_\t$m{$_}\n" for sort keys %m
1462+ pdl > p "$_\t$m{$_}\n" for sort keys %m
14671463
14681464 F 40.4225352112676
14691465 F_df [2 7]
@@ -1656,30 +1652,30 @@ Usage:
16561652
16571653 # suppose this is whether a person had rented 10 movies
16581654
1659- perldl > p $y = ushort( random(10)*2 )
1655+ pdl > p $y = ushort( random(10)*2 )
16601656 [0 0 0 1 1 0 0 1 1 1]
16611657
16621658 # IV 1 is box office ranking
16631659
1664- perldl > p $x1 = sequence(10)
1660+ pdl > p $x1 = sequence(10)
16651661 [0 1 2 3 4 5 6 7 8 9]
16661662
16671663 # IV 2 is whether the movie is action- or chick-flick
16681664
1669- perldl > p $x2 = sequence(10) % 2
1665+ pdl > p $x2 = sequence(10) % 2
16701666 [0 1 0 1 0 1 0 1 0 1]
16711667
16721668 # concatenate the IVs together
16731669
1674- perldl > p $x = cat $x1, $x2
1670+ pdl > p $x = cat $x1, $x2
16751671 [
16761672 [0 1 2 3 4 5 6 7 8 9]
16771673 [0 1 0 1 0 1 0 1 0 1]
16781674 ]
16791675
1680- perldl > %m = $y->logistic( $x )
1676+ pdl > %m = $y->logistic( $x )
16811677
1682- perldl > p "$_\t$m{$_}\n" for sort keys %m
1678+ pdl > p "$_\t$m{$_}\n" for sort keys %m
16831679
16841680 D0 13.8629436111989
16851681 Dm 9.8627829791575
@@ -1694,8 +1690,8 @@ Usage:
16941690 y_pred [0.10715577 0.23683909 ... 0.76316091 0.89284423]
16951691
16961692 # to get the covariance out, supply a true value for the COV option:
1697- perldl > %m = $y->logistic( $x, {COV=>1} )
1698- perldl > p $m{cov};
1693+ pdl > %m = $y->logistic( $x, {COV=>1} )
1694+ pdl > p $m{cov};
16991695
17001696=cut
17011697
@@ -1909,18 +1905,18 @@ Default options (case insensitive):
19091905Usage:
19101906
19111907 # let's see if we replicated the Osgood et al. (1957) study
1912- perldl > ($data, $idv, $ido) = rtable 'osgood_exp.csv', {v=>0}
1908+ pdl > ($data, $idv, $ido) = rtable 'osgood_exp.csv', {v=>0}
19131909
19141910 # select a subset of var to do pca
1915- perldl > $ind = which_id $idv, [qw( ACTIVE BASS BRIGHT CALM FAST GOOD HAPPY HARD LARGE HEAVY )]
1916- perldl > $data = $data( ,$ind)->sever
1917- perldl > @$idv = @$idv[list $ind]
1911+ pdl > $ind = which_id $idv, [qw( ACTIVE BASS BRIGHT CALM FAST GOOD HAPPY HARD LARGE HEAVY )]
1912+ pdl > $data = $data( ,$ind)->sever
1913+ pdl > @$idv = @$idv[list $ind]
19181914
1919- perldl > %m = $data->pca
1915+ pdl > %m = $data->pca
19201916
1921- perldl > ($iv, $ic) = $m{loadings}->pca_sorti()
1917+ pdl > ($iv, $ic) = $m{loadings}->pca_sorti()
19221918
1923- perldl > p "$idv->[$_]\t" . $m{loadings}->($_,$ic)->flat . "\n" for (list $iv)
1919+ pdl > p "$idv->[$_]\t" . $m{loadings}->($_,$ic)->flat . "\n" for (list $iv)
19241920
19251921 # COMP0 COMP1 COMP2 COMP3
19261922 HAPPY [0.860191 0.364911 0.174372 -0.10484]
0 commit comments