-
Mathematica - Slot (#n)
I am trying to more easily display a plot of four functions by using slot but I am having trouble getting it to work:
Plot[PDF[FRatioDistribution[#1, #2], x] &[{1, 10}, {1, 10}], {x, 0, 3}, PlotStyle -> {Red, Green, Blue, Yellow}]
Basically, I want a plot of four F-distributions with parameters (1,1), (1,10), (10,1), (10,10)
I almost had it working with another distribution (it works except for the coloring):
Plot[(E^(-(Sqrt[(2 k)/#1] - #3)^2/(2*(#2)^2)) + E^(-(-Sqrt[((2 k)/#1)] - #3)^2/(2*(#2)^2)))/(2*#2*Sqrt[\[Pi]*#1*k]) &[1, 2, {0, 1, 2}], {k, 0, 4}, PlotRange -> {0, 0.3}, Filling -> Axis, PlotStyle -> {Red, Green, Blue}]
Oddly, if I evaluate this on separate lines the coloring works correctly:
(E^(-(Sqrt[(2 k)/#1] - #3)^2/(2*(#2)^2)) + E^(-(-Sqrt[((2 k)/#1)] - #3)^2/(2*(#2)^2)))/(2*#2*Sqrt[\[Pi]*#1*k]) &[1, 2, {0, 1, 2}]
Plot[%, {k, 0, 4}, PlotRange -> {0, 0.3}, Filling -> Axis, PlotStyle -> {Red, Green, Blue}]
Any help would be greatly appreciated.
-
Simpler Question
Maybe I should attack this question in stages. Does anyone know why this works as I would expect:
#1 + #2 &[1, {1, 2}]
={2, 3}
but this does not:
#1 + #2 &[{1, 2}, {1, 2}]
={2, 4}
I would like it to give {2, 3, 4}. I know this can be done with table, but I am trying to learn how to use the power of Slot. Thanks.