Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
66
Task/Demings-funnel/ALGOL-68/demings-funnel.alg
Normal file
66
Task/Demings-funnel/ALGOL-68/demings-funnel.alg
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
BEGIN # Deming's funnel - translated from Python #
|
||||
PR read "rows.incl.a68" PR # include row (array) utilities #
|
||||
|
||||
PROC funnel = ( INT rule, []REAL dxs )[]REAL:
|
||||
BEGIN
|
||||
[ LWB dxs : UPB dxs ]REAL rvs; REAL v := 0;
|
||||
FOR dx pos FROM LWB dxs TO UPB dxs DO
|
||||
REAL dx = dxs[ dx pos ];
|
||||
rvs[ dx pos ] := v + dx;
|
||||
IF rule = 1 THEN
|
||||
v := 0
|
||||
ELIF rule = 2 THEN
|
||||
v := - dx
|
||||
ELIF rule = 3 THEN
|
||||
v := - ( v + dx )
|
||||
ELSE
|
||||
v +:= dx
|
||||
FI
|
||||
OD;
|
||||
rvs
|
||||
END # funnel # ;
|
||||
|
||||
PROC experiment = ( INT rule, []REAL dxs, dys )VOID:
|
||||
BEGIN
|
||||
[]REAL rxs = funnel( rule, dxs );
|
||||
[]REAL rys = funnel( rule, dys );
|
||||
print( ( "Rule ", whole( rule, - 4 ), ": " ) );
|
||||
print( ( "Mean x, y : ", fixed( AVERAGE rxs, -8, 4 ) ) );
|
||||
print( ( " ", fixed( AVERAGE rys, -8, 4 ), newline ) );
|
||||
print( ( " " ) );
|
||||
print( ( "Std dev x, y : ", fixed( STANDARDDEVIATION rxs, -8, 4 ) ) );
|
||||
print( ( " ", fixed( STANDARDDEVIATION rys, -8, 4 ), newline ) );
|
||||
print( ( newline ) )
|
||||
END # experiment # ;
|
||||
|
||||
BEGIN
|
||||
[]REAL dxs =
|
||||
( -0.533, 0.27, 0.859, -0.043, -0.205, -0.127, -0.071, 0.275, 1.251, -0.231, -0.401
|
||||
, 0.269, 0.491, 0.951, 1.15, 0.001, -0.382, 0.161, 0.915, 2.08, -2.337, 0.034
|
||||
, -0.126, 0.014, 0.709, 0.129, -1.093, -0.483, -1.193, 0.02, -0.051, 0.047, -0.095
|
||||
, 0.695, 0.34, -0.182, 0.287, 0.213, -0.423, -0.021, -0.134, 1.798, 0.021, -1.099
|
||||
, -0.361, 1.636, -1.134, 1.315, 0.201, 0.034, 0.097, -0.17, 0.054, -0.553, -0.024
|
||||
, -0.181, -0.7, -0.361, -0.789, 0.279, -0.174, -0.009, -0.323, -0.658, 0.348, -0.528
|
||||
, 0.881, 0.021, -0.853, 0.157, 0.648, 1.774, -1.043, 0.051, 0.021, 0.247, -0.31
|
||||
, 0.171, 0.0, 0.106, 0.024, -0.386, 0.962, 0.765, -0.125, -0.289, 0.521, 0.017
|
||||
, 0.281, -0.749, -0.149, -2.436, -0.909, 0.394, -0.113, -0.598, 0.443, -0.521, -0.799
|
||||
, 0.087
|
||||
);
|
||||
[]REAL dys =
|
||||
( 0.136, 0.717, 0.459, -0.225, 1.392, 0.385, 0.121, -0.395, 0.49, -0.682, -0.065
|
||||
, 0.242, -0.288, 0.658, 0.459, 0.0, 0.426, 0.205, -0.765, -2.188, -0.742, -0.01
|
||||
, 0.089, 0.208, 0.585, 0.633, -0.444, -0.351, -1.087, 0.199, 0.701, 0.096, -0.025
|
||||
, -0.868, 1.051, 0.157, 0.216, 0.162, 0.249, -0.007, 0.009, 0.508, -0.79, 0.723
|
||||
, 0.881, -0.508, 0.393, -0.226, 0.71, 0.038, -0.217, 0.831, 0.48, 0.407, 0.447
|
||||
, -0.295, 1.126, 0.38, 0.549, -0.445, -0.046, 0.428, -0.074, 0.217, -0.822, 0.491
|
||||
, 1.347, -0.141, 1.23, -0.044, 0.079, 0.219, 0.698, 0.275, 0.056, 0.031, 0.421
|
||||
, 0.064, 0.721, 0.104, -0.729, 0.65, -1.103, 0.154, -1.72, 0.051, -0.385, 0.477
|
||||
, 1.537, -0.901, 0.939, -0.411, 0.341, -0.411, 0.106, 0.224, -0.947, -1.424, -0.542
|
||||
, -1.032
|
||||
);
|
||||
experiment( 1, dxs, dys );
|
||||
experiment( 2, dxs, dys );
|
||||
experiment( 3, dxs, dys );
|
||||
experiment( 4, dxs, dys )
|
||||
END
|
||||
END
|
||||
63
Task/Demings-funnel/PascalABC.NET/demings-funnel.pas
Normal file
63
Task/Demings-funnel/PascalABC.NET/demings-funnel.pas
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
const
|
||||
Dxs: array of real =
|
||||
(-0.533, 0.270, 0.859, -0.043, -0.205, -0.127, -0.071, 0.275,
|
||||
1.251, -0.231, -0.401, 0.269, 0.491, 0.951, 1.150, 0.001,
|
||||
-0.382, 0.161, 0.915, 2.080, -2.337, 0.034, -0.126, 0.014,
|
||||
0.709, 0.129, -1.093, -0.483, -1.193, 0.020, -0.051, 0.047,
|
||||
-0.095, 0.695, 0.340, -0.182, 0.287, 0.213, -0.423, -0.021,
|
||||
-0.134, 1.798, 0.021, -1.099, -0.361, 1.636, -1.134, 1.315,
|
||||
0.201, 0.034, 0.097, -0.170, 0.054, -0.553, -0.024, -0.181,
|
||||
-0.700, -0.361, -0.789, 0.279, -0.174, -0.009, -0.323, -0.658,
|
||||
0.348, -0.528, 0.881, 0.021, -0.853, 0.157, 0.648, 1.774,
|
||||
-1.043, 0.051, 0.021, 0.247, -0.310, 0.171, 0.000, 0.106,
|
||||
0.024, -0.386, 0.962, 0.765, -0.125, -0.289, 0.521, 0.017,
|
||||
0.281, -0.749, -0.149, -2.436, -0.909, 0.394, -0.113, -0.598,
|
||||
0.443, -0.521, -0.799, 0.087);
|
||||
|
||||
Dys: array of real =
|
||||
(0.136, 0.717, 0.459, -0.225, 1.392, 0.385, 0.121, -0.395,
|
||||
0.490, -0.682, -0.065, 0.242, -0.288, 0.658, 0.459, 0.000,
|
||||
0.426, 0.205, -0.765, -2.188, -0.742, -0.010, 0.089, 0.208,
|
||||
0.585, 0.633, -0.444, -0.351, -1.087, 0.199, 0.701, 0.096,
|
||||
-0.025, -0.868, 1.051, 0.157, 0.216, 0.162, 0.249, -0.007,
|
||||
0.009, 0.508, -0.790, 0.723, 0.881, -0.508, 0.393, -0.226,
|
||||
0.710, 0.038, -0.217, 0.831, 0.480, 0.407, 0.447, -0.295,
|
||||
1.126, 0.380, 0.549, -0.445, -0.046, 0.428, -0.074, 0.217,
|
||||
-0.822, 0.491, 1.347, -0.141, 1.230, -0.044, 0.079, 0.219,
|
||||
0.698, 0.275, 0.056, 0.031, 0.421, 0.064, 0.721, 0.104,
|
||||
-0.729, 0.650, -1.103, 0.154, -1.720, 0.051, -0.385, 0.477,
|
||||
1.537, -0.901, 0.939, -0.411, 0.341, -0.411, 0.106, 0.224,
|
||||
-0.947, -1.424, -0.542, -1.032);
|
||||
|
||||
function stddev(a: array of real) := a.Sum(x -> Sqr(x - a.average) / a.length).Sqrt;
|
||||
|
||||
function funnel(a: array of real; rule: (real, real) -> real): array of real;
|
||||
begin
|
||||
var x := 0.0;
|
||||
setlength(result, a.length);
|
||||
foreach var val in a index i do
|
||||
begin
|
||||
result[i] := x + val;
|
||||
x := rule(x, val)
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure experiment(lab: string; r: (real, real) -> real);
|
||||
begin
|
||||
var rxs := funnel(Dxs, r);
|
||||
var rys := funnel(Dys, r);
|
||||
lab.println;
|
||||
writeln('Mean x, y: ', rxs.average:6:4, rys.average:8:4);
|
||||
writeln('Std dev x, y: ', stddev(rxs):6:4, stddev(rys):8:4);
|
||||
println;
|
||||
end;
|
||||
|
||||
begin
|
||||
experiment('Rule 1', (z, dz) -> 0.0);
|
||||
|
||||
experiment('Rule 2', (z, dz) -> -dz);
|
||||
|
||||
experiment('Rule 3', (z, dz) -> -(z + dz));
|
||||
|
||||
experiment('Rule 4', (z, dz) -> z + dz);
|
||||
end.
|
||||
45
Task/Demings-funnel/Rust/demings-funnel.rs
Normal file
45
Task/Demings-funnel/Rust/demings-funnel.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
use statrs::statistics::Statistics;
|
||||
|
||||
fn funnel(pseudo_random: &Vec<f64>, rule: fn(f64, f64) -> f64) -> Vec<f64> {
|
||||
let mut value = 0.0;
|
||||
let mut result = vec![0.0; pseudo_random.len()];
|
||||
for i in 0..pseudo_random.len() {
|
||||
result[i] = value + pseudo_random[i];
|
||||
value = rule(value, pseudo_random[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
fn experiment(label: &str, pseudo_random_xs: &Vec<f64>, pseudo_random_ys: &Vec<f64>, rule: fn(f64, f64) -> f64) {
|
||||
let result_x = funnel(pseudo_random_xs, rule);
|
||||
let result_y = funnel(pseudo_random_ys, rule);
|
||||
|
||||
println!("{}\n{}", label, "-----------------------------------------");
|
||||
println!("Mean x, y: {:>8.4}, {:<8.4}", (&result_x).mean(), (&result_y).mean());
|
||||
println!("Standard deviation x, y:{:>8.4}, {:<8.4}\n", result_x.std_dev(), result_y.std_dev());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let pseudo_random_xs = vec![ -0.533, 0.270, 0.859, -0.043, -0.205, -0.127, -0.071,
|
||||
0.275, 1.251, -0.231, -0.401, 0.269, 0.491, 0.951, 1.150, 0.001, -0.382, 0.161, 0.915, 2.080, -2.337,
|
||||
0.034, -0.126, 0.014, 0.709, 0.129, -1.093, -0.483, -1.193, 0.020, -0.051, 0.047, -0.095, 0.695, 0.340,
|
||||
-0.182, 0.287, 0.213, -0.423, -0.021, -0.134, 1.798, 0.021, -1.099, -0.361, 1.636, -1.134, 1.315,
|
||||
0.201, 0.034, 0.097, -0.170, 0.054, -0.553, -0.024, -0.181, -0.700, -0.361, -0.789, 0.279, -0.174,
|
||||
-0.009, -0.323, -0.658, 0.348, -0.528, 0.881, 0.021, -0.853, 0.157, 0.648, 1.774, -1.043, 0.051,
|
||||
0.021, 0.247, -0.310, 0.171, 0.000, 0.106, 0.024, -0.386, 0.962, 0.765, -0.125, -0.289, 0.521,
|
||||
0.017, 0.281, -0.749, -0.149, -2.436, -0.909, 0.394, -0.113, -0.598, 0.443, -0.521, -0.799, 0.087 ];
|
||||
|
||||
let pseudo_random_ys = vec![0.136, 0.717, 0.459, -0.225, 1.392, 0.385, 0.121, -0.395,
|
||||
0.490, -0.682, -0.065, 0.242, -0.288, 0.658, 0.459, 0.000, 0.426, 0.205, -0.765, -2.188, -0.742,
|
||||
-0.010, 0.089, 0.208, 0.585, 0.633, -0.444, -0.351, -1.087, 0.199, 0.701, 0.096, -0.025, -0.868, 1.051,
|
||||
0.157, 0.216, 0.162, 0.249, -0.007, 0.009, 0.508, -0.790, 0.723, 0.881, -0.508, 0.393, -0.226, 0.710,
|
||||
0.038, -0.217, 0.831, 0.480, 0.407, 0.447, -0.295, 1.126, 0.380, 0.549, -0.445, -0.046, 0.428, -0.074,
|
||||
0.217, -0.822, 0.491, 1.347, -0.141, 1.230, -0.044, 0.079, 0.219, 0.698, 0.275, 0.056, 0.031, 0.421, 0.064,
|
||||
0.721, 0.104, -0.729, 0.650, -1.103, 0.154, -1.720, 0.051, -0.385, 0.477, 1.537, -0.901, 0.939, -0.411,
|
||||
0.341, -0.411, 0.106, 0.224, -0.947, -1.424, -0.542, -1.032];
|
||||
|
||||
experiment("Rule 1:", &pseudo_random_xs, &pseudo_random_ys, |_z, _dz| {0.0});
|
||||
experiment("Rule 2:", &pseudo_random_xs, &pseudo_random_ys, |_z, dz| {-dz});
|
||||
experiment("Rule 3:", &pseudo_random_xs, &pseudo_random_ys, |z, dz| {-(z + dz)});
|
||||
experiment("Rule 4:", &pseudo_random_xs, &pseudo_random_ys, |z, dz| {z + dz});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue