~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/plugins/distributions/plot_dist_common.php

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2008-04-20 21:30:00 UTC
  • mfrom: (1.2.2 upstream) (3.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080420213000-fs4i8efmfc793bnn
new upstream release
closes: #475175
closes: #463348
closes: #475982

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?
 
2
function preprocess () {
 
3
}
 
4
 
 
5
function calculate () {
 
6
}
 
7
 
 
8
function printout () {
 
9
        doPrintout (true);
 
10
}
 
11
 
 
12
function preview () {
 
13
        preprocess ();
 
14
        calculate ();
 
15
        doPrintout (false);
 
16
}
 
17
 
 
18
// get the range parameters for the continuous distributions (it's all the same for these)
 
19
function getContRangeParameters () {
 
20
        global $options;
 
21
 
 
22
        $options['n'] = getRK_val ("n");
 
23
        $options['min'] = getRK_val ("min");
 
24
        $options['max'] = getRK_val ("max");
 
25
}
 
26
 
 
27
// get the range parameters for the discontinuous distributions (it's all the same for these)
 
28
function getDiscontRangeParameters () {
 
29
        global $options;
 
30
 
 
31
        $options['min'] = getRK_val ("min");
 
32
        $options['max'] = getRK_val ("max");
 
33
        $options['n'] = $options['max'] - $options['min'] + 1;
 
34
}
 
35
 
 
36
function doPrintout ($final) {
 
37
        global $options;
 
38
 
 
39
        $fun = getRK_val ("function");
 
40
        $log = (getRK_val ("log") == 1);
 
41
        $log_option = "";
 
42
        if ($fun == "d") {
 
43
                $is_density = true;
 
44
                $label = "density";
 
45
                $tail_option = "";
 
46
                $tail_label = "";
 
47
                if ($log) $log_option = ", log=TRUE";
 
48
        } else {
 
49
                $is_density = false;
 
50
                $label = "distribution";
 
51
                if (getRK_val("lower") == "1") {
 
52
                        $tail_option = ", lower.tail = TRUE";
 
53
                        $tail_label = ", \"Tail\",\"Lower\"";
 
54
                } else {
 
55
                        $tail_option = ", lower.tail = FALSE";
 
56
                        $tail_label = ", \"Tail\",\"Upper\"";
 
57
                }
 
58
                if ($log) $log_option = ", log.p=TRUE";
 
59
        }
 
60
        if ($log) $log_label = ', "Scale", "logarithmic"';
 
61
        else $log_label = ', "Scale", "normal"';
 
62
 
 
63
        $options = array ();
 
64
        $options['is_density'] = $is_density;
 
65
        $options['label'] = $label;
 
66
        $options['tail_option'] = $tail_option;
 
67
        $options['tail_label'] = $tail_label;
 
68
        $options['log_option'] = $log_option;
 
69
        $options['log_label'] = $log_label;
 
70
 
 
71
        getParameters ();
 
72
 
 
73
        if ($final) {
 
74
                doHeader (); ?>
 
75
 
 
76
rk.graph.on ()
 
77
<?      }
 
78
?>
 
79
try ({
 
80
        curve (<? doFunCall (); ?>, from=<? echo ($options['min']); ?>, to=<? echo ($options['max']); ?>, n=<? echo ($options['n']); ?><? getRK ("plotoptions.code.printout"); ?>)
 
81
<?      
 
82
        $plot_adds = getRK_val ("plotoptions.code.calculate");
 
83
        if (!empty ($plot_adds)) { ?>
 
84
 
 
85
<?
 
86
                printIndented ("\t", $plot_adds);
 
87
        } ?>
 
88
})
 
89
<?      if ($final) { ?>
 
90
rk.graph.off ()
 
91
<? }
 
92
}
 
93
?>