13 lines
539 B
Text
13 lines
539 B
Text
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]
|