Deming's funnel: Difference between revisions

Content added Content deleted
m (Thundergnat moved page Deming's Funnel to Deming's funnel: capitalization policy)
m (syntax highlighting fixup automation)
Line 23: Line 23:
{{trans|Python}}
{{trans|Python}}


<lang 11l>V dxs = [-0.533, 0.27, 0.859, -0.043, -0.205, -0.127, -0.071, 0.275, 1.251,
<syntaxhighlight lang="11l">V 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,
-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,
2.08, -2.337, 0.034, -0.126, 0.014, 0.709, 0.129, -1.093, -0.483, -1.193,
Line 71: Line 71:
experiment(‘Rule 2:’, (z, dz) -> -dz)
experiment(‘Rule 2:’, (z, dz) -> -dz)
experiment(‘Rule 3:’, (z, dz) -> -(z + dz))
experiment(‘Rule 3:’, (z, dz) -> -(z + dz))
experiment(‘Rule 4:’, (z, dz) -> z + dz)</lang>
experiment(‘Rule 4:’, (z, dz) -> z + dz)</syntaxhighlight>


{{out}}
{{out}}
Line 95: Line 95:
=={{header|Ada}}==
=={{header|Ada}}==
{{trans|Go}}
{{trans|Go}}
<lang Ada>with Ada.Numerics.Elementary_Functions;
<syntaxhighlight lang="ada">with Ada.Numerics.Elementary_Functions;
with Ada.Text_IO;
with Ada.Text_IO;


Line 199: Line 199:
Experiment ("Rule 3", Rule_3'Access);
Experiment ("Rule 3", Rule_3'Access);
Experiment ("Rule 4", Rule_4'Access);
Experiment ("Rule 4", Rule_4'Access);
end Demings_Funnel;</lang>
end Demings_Funnel;</syntaxhighlight>


=={{header|D}}==
=={{header|D}}==
{{trans|Python}}
{{trans|Python}}
<lang d>import std.stdio, std.math, std.algorithm, std.range, std.typecons;
<syntaxhighlight lang="d">import std.stdio, std.math, std.algorithm, std.range, std.typecons;


auto mean(T)(in T[] xs) pure nothrow @nogc {
auto mean(T)(in T[] xs) pure nothrow @nogc {
Line 279: Line 279:
experiment("Rule 3:", dxs, dys, (z, dz) => -(z + dz));
experiment("Rule 3:", dxs, dys, (z, dz) => -(z + dz));
experiment("Rule 4:", dxs, dys, (z, dz) => z + dz);
experiment("Rule 4:", dxs, dys, (z, dz) => z + dz);
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Rule 1:
<pre>Rule 1:
Line 299: Line 299:
=={{header|Elixir}}==
=={{header|Elixir}}==
{{trans|Ruby}}
{{trans|Ruby}}
<lang elixir>defmodule Deming do
<syntaxhighlight lang="elixir">defmodule Deming do
def funnel(dxs, rule) do
def funnel(dxs, rule) do
{_, rxs} = Enum.reduce(dxs, {0, []}, fn dx,{x,rxs} ->
{_, rxs} = Enum.reduce(dxs, {0, []}, fn dx,{x,rxs} ->
Line 354: Line 354:
Deming.experiment("Rule 2:", dxs, dys, fn _z, dz -> -dz end)
Deming.experiment("Rule 2:", dxs, dys, fn _z, dz -> -dz end)
Deming.experiment("Rule 3:", dxs, dys, fn z, dz -> -(z+dz) end)
Deming.experiment("Rule 3:", dxs, dys, fn z, dz -> -(z+dz) end)
Deming.experiment("Rule 4:", dxs, dys, fn z, dz -> z+dz end)</lang>
Deming.experiment("Rule 4:", dxs, dys, fn z, dz -> z+dz end)</syntaxhighlight>


{{out}}
{{out}}
Line 377: Line 377:
=={{header|Factor}}==
=={{header|Factor}}==
{{works with|Factor|0.99 2019-10-06}}
{{works with|Factor|0.99 2019-10-06}}
<lang factor>USING: combinators formatting generalizations grouping.extras io
<syntaxhighlight lang="factor">USING: combinators formatting generalizations grouping.extras io
kernel math math.statistics sequences ;
kernel math math.statistics sequences ;


Line 420: Line 420:
[ "Rule 3:" print [ 0 [ - neg ] accumulate* ] bi@ ]
[ "Rule 3:" print [ 0 [ - neg ] accumulate* ] bi@ ]
[ "Rule 4:" print [ cum-sum ] bi@ ]
[ "Rule 4:" print [ cum-sum ] bi@ ]
} [ show ] map-compose 2cleave</lang>
} [ show ] map-compose 2cleave</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 439: Line 439:
=={{header|Go}}==
=={{header|Go}}==
{{trans|Python}}
{{trans|Python}}
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 529: Line 529:
return z + dz
return z + dz
})
})
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 552: Line 552:
=={{header|Haskell}}==
=={{header|Haskell}}==
{{trans|Python}}
{{trans|Python}}
<lang haskell>import Data.List (mapAccumL, genericLength)
<syntaxhighlight lang="haskell">import Data.List (mapAccumL, genericLength)
import Text.Printf
import Text.Printf


Line 608: Line 608:
experiment "Rule 2:" dxs dys (\_ dz -> -dz)
experiment "Rule 2:" dxs dys (\_ dz -> -dz)
experiment "Rule 3:" dxs dys (\z dz -> -(z+dz))
experiment "Rule 3:" dxs dys (\z dz -> -(z+dz))
experiment "Rule 4:" dxs dys (\z dz -> z+dz)</lang>
experiment "Rule 4:" dxs dys (\z dz -> z+dz)</syntaxhighlight>


{{out}}
{{out}}
Line 631: Line 631:
=={{header|J}}==
=={{header|J}}==


<syntaxhighlight lang="j">
<lang J>
dx=:".0 :0-.LF
dx=:".0 :0-.LF
_0.533 0.270 0.859 _0.043 _0.205 _0.127 _0.071 0.275
_0.533 0.270 0.859 _0.043 _0.205 _0.127 _0.071 0.275
Line 683: Line 683:
smoutput ' Rule 4 (x,y):'
smoutput ' Rule 4 (x,y):'
smoutput ' Mean: ',":dx ,&mean&Rule4 dy
smoutput ' Mean: ',":dx ,&mean&Rule4 dy
smoutput ' Std dev: ',":dx ,&stddev&Rule4 dy</lang>
smoutput ' Std dev: ',":dx ,&stddev&Rule4 dy</syntaxhighlight>


Displayed result:
Displayed result:
Line 708: Line 708:
Translation of [[Deming's_Funnel#Python|Python]] via [[Deming's_Funnel#D|D]]
Translation of [[Deming's_Funnel#Python|Python]] via [[Deming's_Funnel#D|D]]
{{works with|Java|8}}
{{works with|Java|8}}
<lang java>import static java.lang.Math.*;
<syntaxhighlight lang="java">import static java.lang.Math.*;
import java.util.Arrays;
import java.util.Arrays;
import java.util.function.BiFunction;
import java.util.function.BiFunction;
Line 782: Line 782:
return sqrt(Arrays.stream(xs).map(x -> pow((x - m), 2)).sum() / xs.length);
return sqrt(Arrays.stream(xs).map(x -> pow((x - m), 2)).sum() / xs.length);
}
}
}</lang>
}</syntaxhighlight>


<pre>Rule 1:
<pre>Rule 1:
Line 801: Line 801:


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia># Run from Julia REPL to see the plots.
<syntaxhighlight lang="julia"># Run from Julia REPL to see the plots.
using Statistics, Distributions, Plots
using Statistics, Distributions, Plots


Line 856: Line 856:
testfunnel(false)
testfunnel(false)
display(plots)
display(plots)
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
Using Racket data.
Using Racket data.
Line 881: Line 881:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|Python}}
{{trans|Python}}
<lang scala>// version 1.1.3
<syntaxhighlight lang="scala">// version 1.1.3


typealias Rule = (Double, Double) -> Double
typealias Rule = (Double, Double) -> Double
Line 948: Line 948:
experiment("Rule 3") { z, dz -> -(z + dz) }
experiment("Rule 3") { z, dz -> -(z + dz) }
experiment("Rule 4") { z, dz -> z + dz }
experiment("Rule 4") { z, dz -> z + dz }
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 970: Line 970:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>dxs = {-0.533, 0.27, 0.859, -0.043, -0.205, -0.127, -0.071, 0.275,
<syntaxhighlight lang="mathematica">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,
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.161, 0.915, 2.08, -2.337, 0.034, -0.126, 0.014, 0.709,
Line 1,019: Line 1,019:
];
];


TableForm[Results[#, Transpose[{dxs, dys}]] & /@ Range[4], TableSpacing -> 5]</lang>
TableForm[Results[#, Transpose[{dxs, dys}]] & /@ Range[4], TableSpacing -> 5]</syntaxhighlight>
{{out}}
{{out}}
<pre>Rule 1
<pre>Rule 1
Line 1,038: Line 1,038:


== Stretch 1 ==
== Stretch 1 ==
<syntaxhighlight lang="mathematica">
<lang Mathematica>
RadiusDistribution = NormalDistribution[0, 1];
RadiusDistribution = NormalDistribution[0, 1];
AngleDistribution = UniformDistribution[{0, Pi}];
AngleDistribution = UniformDistribution[{0, Pi}];
Line 1,052: Line 1,052:


TableForm[Results[#, newData] & /@ Range[4], TableSpacing -> 5]
TableForm[Results[#, newData] & /@ Range[4], TableSpacing -> 5]
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 1,075: Line 1,075:


== Stretch 2 ==
== Stretch 2 ==
<syntaxhighlight lang="mathematica">
<lang Mathematica>
ListPlot[MarblePositions[#][Transpose[{dxs,dys}]]&/@Range[4],PlotLegends->PointLegend[{1,2,3,4}],AspectRatio->Automatic,ImageSize->600]
ListPlot[MarblePositions[#][Transpose[{dxs,dys}]]&/@Range[4],PlotLegends->PointLegend[{1,2,3,4}],AspectRatio->Automatic,ImageSize->600]
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 1,084: Line 1,084:
=={{header|Nim}}==
=={{header|Nim}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<lang Nim>import stats, strformat
<syntaxhighlight lang="nim">import stats, strformat


type Rule = proc(x, y: float): float
type Rule = proc(x, y: float): float
Line 1,137: Line 1,137:
experiment("Rule 3", proc(z, dz: float): float = -(z + dz))
experiment("Rule 3", proc(z, dz: float): float = -(z + dz))


experiment("Rule 4", proc(z, dz: float): float = z + dz)</lang>
experiment("Rule 4", proc(z, dz: float): float = z + dz)</syntaxhighlight>


{{out}}
{{out}}
Line 1,158: Line 1,158:
=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
:''This is a work-in-progress.''
:''This is a work-in-progress.''
<lang parigp>drop(drops, rule, rnd)={
<syntaxhighlight lang="parigp">drop(drops, rule, rnd)={
my(v=vector(drops),target=0);
my(v=vector(drops),target=0);
v[1]=rule(target, 0);
v[1]=rule(target, 0);
Line 1,183: Line 1,183:
print()
print()
)
)
}</lang>
}</syntaxhighlight>


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>@dx = qw<
<syntaxhighlight lang="perl">@dx = qw<
-0.533 0.270 0.859 -0.043 -0.205 -0.127 -0.071 0.275
-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
1.251 -0.231 -0.401 0.269 0.491 0.951 1.150 0.001
Line 1,236: Line 1,236:
printf "Mean x, y : %7.4f %7.4f\n", mean(@ddx), mean(@ddy);
printf "Mean x, y : %7.4f %7.4f\n", mean(@ddx), mean(@ddy);
printf "Std dev x, y : %7.4f %7.4f\n", stddev(@ddx), stddev(@ddy);
printf "Std dev x, y : %7.4f %7.4f\n", stddev(@ddx), stddev(@ddy);
}</lang>
}</syntaxhighlight>
{{out}}<pre>
{{out}}<pre>
Rule 1
Rule 1
Line 1,252: Line 1,252:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">funnel</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">dxs</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">rule</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">funnel</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">dxs</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">rule</span><span style="color: #0000FF;">)</span>
Line 1,316: Line 1,316:
<span style="color: #000000;">experiment</span><span style="color: #0000FF;">(</span><span style="color: #000000;">i</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">dxs</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">dys</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">experiment</span><span style="color: #0000FF;">(</span><span style="color: #000000;">i</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">dxs</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">dys</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 1,331: Line 1,331:
=={{header|Python}}==
=={{header|Python}}==
{{trans|Racket}}
{{trans|Racket}}
<lang python>import math
<syntaxhighlight lang="python">import math


dxs = [-0.533, 0.27, 0.859, -0.043, -0.205, -0.127, -0.071, 0.275, 1.251,
dxs = [-0.533, 0.27, 0.859, -0.043, -0.205, -0.127, -0.071, 0.275, 1.251,
Line 1,380: Line 1,380:
experiment('Rule 2:', lambda z, dz: -dz)
experiment('Rule 2:', lambda z, dz: -dz)
experiment('Rule 3:', lambda z, dz: -(z+dz))
experiment('Rule 3:', lambda z, dz: -(z+dz))
experiment('Rule 4:', lambda z, dz: z+dz)</lang>
experiment('Rule 4:', lambda z, dz: z+dz)</syntaxhighlight>


{{output}}
{{output}}
Line 1,401: Line 1,401:


'''Alternative''': [Generates pseudo-random data and gives some interpretation.] The funnel experiment is performed in one dimension. The other dimension would act similarly.
'''Alternative''': [Generates pseudo-random data and gives some interpretation.] The funnel experiment is performed in one dimension. The other dimension would act similarly.
<lang python>from random import gauss
<syntaxhighlight lang="python">from random import gauss
from math import sqrt
from math import sqrt
from pprint import pprint as pp
from pprint import pprint as pp
Line 1,475: Line 1,475:
for rule, comment in rcomments:
for rule, comment in rcomments:
printit(rule)
printit(rule)
print(' %s\n' % comment)</lang>
print(' %s\n' % comment)</syntaxhighlight>


{{out}}
{{out}}
Line 1,523: Line 1,523:
=={{header|Racket}}==
=={{header|Racket}}==
The stretch solutions can be obtained by uncommenting radii etc. (delete the 4 semi-colons) to generate fresh data, and scatter-plots can be obtained by deleting the #; .
The stretch solutions can be obtained by uncommenting radii etc. (delete the 4 semi-colons) to generate fresh data, and scatter-plots can be obtained by deleting the #; .
<lang racket>#lang racket
<syntaxhighlight lang="racket">#lang racket
(require math/distributions math/statistics plot)
(require math/distributions math/statistics plot)


Line 1,573: Line 1,573:
(experiment "Rule 2:" (λ (z dz) (- dz)))
(experiment "Rule 2:" (λ (z dz) (- dz)))
(experiment "Rule 3:" (λ (z dz) (- (+ z dz))))
(experiment "Rule 3:" (λ (z dz) (- (+ z dz))))
(experiment "Rule 4:" (λ (z dz) (+ z dz))) </lang>
(experiment "Rule 4:" (λ (z dz) (+ z dz))) </syntaxhighlight>


{{output}}
{{output}}
Line 1,597: Line 1,597:
(formerly Perl 6)
(formerly Perl 6)
{{Works with|Rakudo|2018.10}}
{{Works with|Rakudo|2018.10}}
<lang perl6>sub mean { @_ R/ [+] @_ }
<syntaxhighlight lang="raku" line>sub mean { @_ R/ [+] @_ }
sub stddev {
sub stddev {
# <(x - <x>)²> = <x²> - <x>²
# <(x - <x>)²> = <x²> - <x>²
Line 1,649: Line 1,649:
printf "Mean x, y : %7.4f %7.4f\n", mean(@z».re), mean(@z».im);
printf "Mean x, y : %7.4f %7.4f\n", mean(@z».re), mean(@z».im);
printf "Std dev x, y : %7.4f %7.4f\n", stddev(@z».re), stddev(@z».im);
printf "Std dev x, y : %7.4f %7.4f\n", stddev(@z».re), stddev(@z».im);
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Rule 1:
<pre>Rule 1:
Line 1,666: Line 1,666:
=={{header|Ruby}}==
=={{header|Ruby}}==
{{trans|Python}}
{{trans|Python}}
<lang ruby>def funnel(dxs, &rule)
<syntaxhighlight lang="ruby">def funnel(dxs, &rule)
x, rxs = 0, []
x, rxs = 0, []
for dx in dxs
for dx in dxs
Line 1,721: Line 1,721:
experiment('Rule 2:', dxs, dys) {|z, dz| -dz}
experiment('Rule 2:', dxs, dys) {|z, dz| -dz}
experiment('Rule 3:', dxs, dys) {|z, dz| -(z+dz)}
experiment('Rule 3:', dxs, dys) {|z, dz| -(z+dz)}
experiment('Rule 4:', dxs, dys) {|z, dz| z+dz}</lang>
experiment('Rule 4:', dxs, dys) {|z, dz| z+dz}</syntaxhighlight>


{{out}}
{{out}}
Line 1,744: Line 1,744:
=={{header|Sidef}}==
=={{header|Sidef}}==
{{trans|Raku}}
{{trans|Raku}}
<lang ruby>func x̄(a) {
<syntaxhighlight lang="ruby">func x̄(a) {
a.sum / a.len
a.sum / a.len
}
}
Line 1,800: Line 1,800:
printf("Mean x, y : %.4f %.4f\n", x̄(z.map{.re}), x̄(z.map{.im}))
printf("Mean x, y : %.4f %.4f\n", x̄(z.map{.re}), x̄(z.map{.im}))
printf("Std dev x, y : %.4f %.4f\n", σ(z.map{.re}), σ(z.map{.im}))
printf("Std dev x, y : %.4f %.4f\n", σ(z.map{.re}), σ(z.map{.im}))
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,821: Line 1,821:
{{trans|Kotlin}}
{{trans|Kotlin}}


<lang swift>import Foundation
<syntaxhighlight lang="swift">import Foundation


let dxs = [
let dxs = [
Line 1,896: Line 1,896:
experiment(label: "Rule 2", rule: {_, dz in -dz })
experiment(label: "Rule 2", rule: {_, dz in -dz })
experiment(label: "Rule 3", rule: {z, dz in -(z + dz) })
experiment(label: "Rule 3", rule: {z, dz in -(z + dz) })
experiment(label: "Rule 4", rule: {z, dz in z + dz })</lang>
experiment(label: "Rule 4", rule: {z, dz in z + dz })</syntaxhighlight>


{{out}}
{{out}}
Line 1,919: Line 1,919:
{{works with|Tcl|8.6}}
{{works with|Tcl|8.6}}
{{trans|Ruby}}
{{trans|Ruby}}
<lang tcl>package require Tcl 8.6
<syntaxhighlight lang="tcl">package require Tcl 8.6
namespace path {tcl::mathop tcl::mathfunc}
namespace path {tcl::mathop tcl::mathfunc}


Line 1,977: Line 1,977:
experiment "Rule 2:" $dxs $dys {{z dz} {expr {-$dz}}}
experiment "Rule 2:" $dxs $dys {{z dz} {expr {-$dz}}}
experiment "Rule 3:" $dxs $dys {{z dz} {expr {-($z+$dz)}}}
experiment "Rule 3:" $dxs $dys {{z dz} {expr {-($z+$dz)}}}
experiment "Rule 4:" $dxs $dys {{z dz} {expr {$z+$dz}}}</lang>
experiment "Rule 4:" $dxs $dys {{z dz} {expr {$z+$dz}}}</syntaxhighlight>
The first stretch goal:
The first stretch goal:
{{tcllib|math::constants}}
{{tcllib|math::constants}}
{{tcllib|simulation::random}}
{{tcllib|simulation::random}}
<lang tcl>package require math::constants
<syntaxhighlight lang="tcl">package require math::constants
package require simulation::random
package require simulation::random


Line 2,000: Line 2,000:
experiment "Rule 2:" $dxs $dys {{z dz} {expr {-$dz}}}
experiment "Rule 2:" $dxs $dys {{z dz} {expr {-$dz}}}
experiment "Rule 3:" $dxs $dys {{z dz} {expr {-($z+$dz)}}}
experiment "Rule 3:" $dxs $dys {{z dz} {expr {-($z+$dz)}}}
experiment "Rule 4:" $dxs $dys {{z dz} {expr {$z+$dz}}}</lang>
experiment "Rule 4:" $dxs $dys {{z dz} {expr {$z+$dz}}}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 2,041: Line 2,041:
=={{header|Vlang}}==
=={{header|Vlang}}==
{{trans|Go}}
{{trans|Go}}
<lang vlang>import math
<syntaxhighlight lang="vlang">import math


type Rule = fn(f64, f64) f64
type Rule = fn(f64, f64) f64
Line 2,128: Line 2,128:
return z + dz
return z + dz
})
})
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 2,152: Line 2,152:
{{trans|Go}}{{libheader|Wren-math}}
{{trans|Go}}{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "/math" for Nums
<syntaxhighlight lang="ecmascript">import "/math" for Nums
import "/fmt" for Fmt
import "/fmt" for Fmt


Line 2,210: Line 2,210:
experiment.call("Rule 2") { |z, dz| -dz }
experiment.call("Rule 2") { |z, dz| -dz }
experiment.call("Rule 3") { |z, dz| -(z + dz) }
experiment.call("Rule 3") { |z, dz| -(z + dz) }
experiment.call("Rule 4") { |z, dz| z + dz }</lang>
experiment.call("Rule 4") { |z, dz| z + dz }</syntaxhighlight>


{{out}}
{{out}}
Line 2,233: Line 2,233:
=={{header|zkl}}==
=={{header|zkl}}==
{{trans|Ruby}}
{{trans|Ruby}}
<lang zkl>fcn funnel(dxs, rule){
<syntaxhighlight lang="zkl">fcn funnel(dxs, rule){
x:=0.0; rxs:=L();
x:=0.0; rxs:=L();
foreach dx in (dxs){
foreach dx in (dxs){
Line 2,255: Line 2,255:
"Std dev x, y : %7.4f, %7.4f".fmt(stddev(rxs),stddev(rys)).println();
"Std dev x, y : %7.4f, %7.4f".fmt(stddev(rxs),stddev(rys)).println();
println();
println();
}</lang>
}</syntaxhighlight>
<lang zkl>dxs:=T( -0.533, 0.270, 0.859, -0.043, -0.205, -0.127, -0.071, 0.275,
<syntaxhighlight lang="zkl">dxs:=T( -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,
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.382, 0.161, 0.915, 2.080, -2.337, 0.034, -0.126, 0.014,
Line 2,287: Line 2,287:
experiment("Rule 2:", dxs, dys, fcn(z,dz){ -dz });
experiment("Rule 2:", dxs, dys, fcn(z,dz){ -dz });
experiment("Rule 3:", dxs, dys, fcn(z,dz){ -(z+dz) });
experiment("Rule 3:", dxs, dys, fcn(z,dz){ -(z+dz) });
experiment("Rule 4:", dxs, dys, fcn(z,dz){ z+dz });</lang>
experiment("Rule 4:", dxs, dys, fcn(z,dz){ z+dz });</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>