Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d194bc8

Browse files
committed
Replace loop with array operations in an example.
1 parent fba02de commit d194bc8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

examples/scales/logit_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
xmax = 10
1515
x = np.linspace(-xmax, xmax, 10000)
1616
cdf_norm = [math.erf(w / np.sqrt(2)) / 2 + 1 / 2 for w in x]
17-
cdf_laplacian = [1 / 2 * np.exp(w) if w < 0 else 1 - 1 / 2 * np.exp(-w)
18-
for w in x]
17+
cdf_laplacian = np.where(x < 0, 1 / 2 * np.exp(x), 1 - 1 / 2 * np.exp(-x))
1918
cdf_cauchy = np.arctan(x) / np.pi + 1 / 2
2019

2120
fig, axs = plt.subplots(nrows=3, ncols=2, figsize=(6.4, 8.5))

0 commit comments

Comments
 (0)