为啥画出来的图有缺口啊?
mathematica吧
全部回复
仅看楼主
level 2
希望小星 楼主
想不通,我设计了下面这个函数:
Zs[z_] := 2 * (1 - CDF[NormalDistribution[0, 1], Abs[z]])
RegionPlot[{Zs[x] <= 0.05 + (1 - 0.05)*Zs[y] && Zs[y] - Zs[x] <= 0,
Zs[y] <= 0.05 + (1 - 0.05)*Zs[x] && Zs[y] - Zs[x] >= 0}, {x, -4,
4}, {y, -4, 4}, PlotStyle -> Blue,
FrameLabel -> {"\!\(\*SubscriptBox[\(p\), \(1\)]\)",
"\!\(\*SubscriptBox[\(p\), \(2\)]\)"}, BoundaryStyle -> None]
这应该是四象限对称的图,怎么用mathematica画出来仿佛缺了一块?
2022年08月19日 04点08分 1
吧务
level 15
“尖”处的分辨率问题。调PlotPoints即可:
RegionPlot[{Zs[x] <= 0.05 + (1 - 0.05)*Zs[y] && Zs[y] - Zs[x] <= 0,
Zs[y] <= 0.05 + (1 - 0.05)*Zs[x] && Zs[y] - Zs[x] >= 0} // Evaluate, {x, -4,
4}, {y, -4, 4}, PlotStyle -> Blue,
FrameLabel -> {"\!\(\*SubscriptBox[\(p\), \(1\)]\)",
"\!\(\*SubscriptBox[\(p\), \(2\)]\)"}, BoundaryStyle -> None,
PlotPoints -> 201] // AbsoluteTiming
如果你的下一个问题是为什么这代码这么慢,那么这里有个快的:
dat = With[{step = 0.005,
expr = Or @@ {Zs[x] <= 0.05 + (1 - 0.05)*Zs[y] && Zs[y] - Zs[x] <= 0,
Zs[y] <= 0.05 + (1 - 0.05)*Zs[x] && Zs[y] - Zs[x] >= 0}},
Compile[{},
Table[If[expr, 1., 0.], {x, -4, 4, step}, {y, -4, 4,
step}]]][]; // AbsoluteTiming
ArrayPlot[dat, ColorRules -> {1. -> Blue}] // AbsoluteTiming
代价是生成的图片不是矢量图。
2022年11月05日 11点11分 2
吧务
level 15
还有,LZ可能会奇怪为什么自己的帖子过了两个半月才有人回,这是因为你的帖子(至少在8月份的时候)仅自己可见了,我也是刚刚翻旧帖才偶然发现了你的帖子。
2022年11月05日 13点11分 3
level 2
希望小星 楼主
非常谢谢!可是帖子为啥会“仅自己可见”?又不是微信。
2022年11月07日 07点11分 4
吧务
level 15
但是这里是贴吧……:https://tieba.baidu.com/p/6149875269
2022年12月03日 03点12分 6
1