Created
August 30, 2017 03:27
-
-
Save JNeiger/03ec0eefb3da3f4a99105ba54ad006f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clear[bUpper, bLower, kmean, kstdev, r1mean, r1stdev, r2mean, \ | |
r2stdev, r3mean, r3stdev] | |
ClearAll["Global'*"] | |
bUpper = 1; bLower = -1; kmean = 0; kstdev = .1; | |
r1stdev = 0.1; r2stdev = 0.1; r3stdev = .1; | |
bounds = UnitStep[x - bUpper] + (1 - UnitStep[x - bLower]); | |
kickdistr = PDF[NormalDistribution[kmean, kstdev], x]; | |
(* "Complement" of a normal distribution*) | |
r1form = Sqrt[2*Pi] * r1stdev * | |
PDF[NormalDistribution[r1mean, r1stdev], x]; | |
r2form = Sqrt[2*Pi] * r2stdev * | |
PDF[NormalDistribution[r2mean, r2stdev], x]; | |
r3form = Sqrt[2*Pi] * r3stdev * | |
PDF[NormalDistribution[r3mean, r3stdev], x]; | |
(* Chance numRobots in this and the other with statement to see the \ | |
different outputs*) | |
With[{numRobots = 3}, | |
Which[ | |
numRobots == 1, robots = r1form , | |
numRobots == 2, robots = r1form + r2form - r1form *r2form , | |
numRobots == 3, | |
robots = r1form + r2form + r3form - r1form *r2form - | |
r1form *r3form - r2form*r3form - r1form*r2form*r3form]] | |
goodkick = 1 - robots - bounds; | |
results = Convolve[goodkick, kickdistr, x, z]; | |
func = Integrate[results, {z, bLower - kstdev, bUpper + kstdev}]; | |
minData = -3; | |
maxData = 3; | |
(* | |
For 1 robot, the X axis is the robot location, the Y axis is the \ | |
total probability | |
For 2 robots, the X and Y axis are the two robot locations, the color \ | |
is the total probability | |
For 3 robots, the X, Y, and Z axis are the three robot locations, the \ | |
color is the total probability | |
*) | |
With[{numRobots = 3}, | |
Which[ | |
numRobots == 1, Plot[func, {r1mean, minData, maxData}], | |
numRobots == 2, | |
Plot3D[func, {r1mean, minData, maxData}, {r2mean, minData, | |
maxData}, PlotPoints -> 50], | |
numRobots == 3, | |
data = Table[-func, {r1mean, minData, maxData}, {r2mean, minData, | |
maxData}, {r3mean, minData, maxData}]; | |
ListContourPlot3D[data, Contours -> 5, Mesh -> None, | |
PlotLegends -> "Expressions"]]] | |
DensityPlot3D[func, {r1mean, minData, maxData}, {r2mean, minData, | |
maxData}, {r3mean, minData, maxData}, PlotLegends -> Automatic] | |
(* Plots a sample probability to score at X angle distribution with 3 \ | |
robots in the way *) | |
r1mean = 0; r2mean = -0.5; r3mean = 0.5; | |
Plot[results, {z, minData, maxData}, Filling -> Axis] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment