Deming's funnel: Difference between revisions

Line 944:
With[
{positions = MarblePositions[rule][diffData]},
StringForm["Rule `1`\nmean: `2`\nstd dev: `3`", rule, Mean[positions], BiasedStandardDeviation[positions]]
Mean[positions], BiasedStandardDeviation[positions]]
];
 
Line 957 ⟶ 956:
mean: {0.0004,0.07023}
std dev: {0.715271,0.646206}
 
Rule 2
mean: {0.00087,-0.01032}
std dev: {1.03714,0.899948}
 
Rule 3
mean: {0.04386,-0.0063}
std dev: {7.98712,4.77842}
 
Rule 4
mean: {3.13412,5.42102}
std dev: {1.58739,3.93036}
</pre>
 
 
== Stretch 1 ==
<lang Mathematica>
RadiusDistribution = NormalDistribution[0, 1];
AngleDistribution = UniformDistribution[{0, Pi}];
 
(*Mathematica has built in transformation functions, but this seems clearer given the way the instructions were written.*)
ToCartesian[{r_, a_}] := ToCartesian[{Abs@r, a - Pi}] /; Negative[r];
ToCartesian[{r_, a_}] := FromPolarCoordinates[{r, a}];
 
newData =
ToCartesian /@
Transpose[{RandomVariate[RadiusDistribution, 100],
RandomVariate[AngleDistribution, 100]}];
 
TableForm[Results[#, newData] & /@ Range[4], TableSpacing -> 5]
</lang>
 
{{out}}
<pre>
Rule 1
mean: {0.0236483,-0.0480581}
std dev: {0.75398,0.678437}
 
Rule 2
mean: {-0.00586115,0.00205628}
std dev: {1.07625,0.922341}
 
Rule 3
mean: {0.0180857,-0.0707311}
std dev: {2.53086,4.29764}
 
Rule 4
mean: {1.78937,-0.132491}
std dev: {2.36082,3.15051}
</pre>
 
 
== Stretch 2 ==
<lang Mathematica>
ListPlot[MarblePositions[#][Transpose[{dxs,dys}]]&/@Range[4],PlotLegends->PointLegend[{1,2,3,4}],AspectRatio->Automatic,ImageSize->600]
</lang>
 
{{out}}
~images disabled~
 
=={{header|Nim}}==
23

edits