|
42 | 42 | " if ax is None:\n", |
43 | 43 | " fig, ax = plt.subplots()\n", |
44 | 44 | "\n", |
45 | | - " sample = distr.sample(10000)\n", |
| 45 | + " sample = distr.sample(20_000)\n", |
46 | 46 | "\n", |
47 | 47 | " # pdf\n", |
48 | 48 | " xmin = min(sample.min(), distr.lb_scaled if distr.bounds is not None else sample.min())\n", |
|
102 | 102 | "cell_type": "code", |
103 | 103 | "source": [ |
104 | 104 | "plot(Normal(10, 2, transformation=LIN))\n", |
105 | | - "plot(Normal(10, 2, transformation=LOG))\n", |
106 | | - "# Note that the log-normal is different from the log-transformed normal distribution:\n", |
107 | | - "plot(LogNormal(10, 2, transformation=LIN))" |
| 105 | + "# Note that log-transformed normal distribution is different from the log-normal distribution\n", |
| 106 | + "plot(Normal(10, 2, transformation=LOG))" |
108 | 107 | ], |
109 | 108 | "id": "f6192c226f179ef9", |
110 | 109 | "outputs": [], |
|
120 | 119 | "metadata": {}, |
121 | 120 | "cell_type": "code", |
122 | 121 | "source": [ |
123 | | - "plot(Uniform(0, 1, transformation=LOG10))\n", |
124 | | - "plot(ParameterScaleUniform(0, 1, transformation=LOG10))\n", |
| 122 | + "# different, because transformation!=LIN\n", |
| 123 | + "plot(Uniform(1e-16, 1, transformation=LOG10))\n", |
| 124 | + "plot(ParameterScaleUniform(1e-16, 1, transformation=LOG10))\n", |
125 | 125 | "\n", |
126 | | - "plot(Uniform(0, 1, transformation=LIN))\n", |
127 | | - "plot(ParameterScaleUniform(0, 1, transformation=LIN))\n" |
| 126 | + "# same, because transformation=LIN\n", |
| 127 | + "plot(Uniform(1e-16, 1, transformation=LIN))\n", |
| 128 | + "plot(ParameterScaleUniform(1e-16, 1, transformation=LIN))\n" |
128 | 129 | ], |
129 | 130 | "id": "5ca940bc24312fc6", |
130 | 131 | "outputs": [], |
|
133 | 134 | { |
134 | 135 | "metadata": {}, |
135 | 136 | "cell_type": "markdown", |
136 | | - "source": "To prevent the sampled parameters from exceeding the bounds, the sampled parameters are clipped to the bounds. The bounds are defined in the parameter table. Note that the current implementation does not support sampling from a truncated distribution. Instead, the samples are clipped to the bounds. This may introduce unwanted bias, and thus, should only be used with caution (i.e., the bounds should be chosen wide enough):", |
| 137 | + "source": "The given distributions are truncated at the bounds defined in the parameter table:", |
137 | 138 | "id": "b1a8b17d765db826" |
138 | 139 | }, |
139 | 140 | { |
140 | 141 | "metadata": {}, |
141 | 142 | "cell_type": "code", |
142 | 143 | "source": [ |
143 | | - "plot(Normal(0, 1, bounds=(-4, 4))) # negligible clipping-bias at 4 sigma\n", |
144 | | - "plot(Uniform(0, 1, bounds=(0.1, 0.9))) # significant clipping-bias" |
| 144 | + "plot(Normal(0, 1, bounds=(-2, 2)))\n", |
| 145 | + "plot(Uniform(0, 1, bounds=(0.1, 0.9)))\n", |
| 146 | + "plot(Uniform(1e-8, 1, bounds=(0.1, 0.9), transformation=LOG10))\n", |
| 147 | + "plot(Laplace(0, 1, bounds=(-0.5, 0.5)))\n", |
| 148 | + "plot(ParameterScaleUniform(-3, 1, bounds=(1e-2, 1), transformation=LOG10))\n" |
145 | 149 | ], |
146 | 150 | "id": "4ac42b1eed759bdd", |
147 | 151 | "outputs": [], |
|
156 | 160 | { |
157 | 161 | "metadata": {}, |
158 | 162 | "cell_type": "code", |
159 | | - "source": [ |
160 | | - "plot(Normal(10, 1, bounds=(6, 14), transformation=\"log10\"))\n", |
161 | | - "plot(ParameterScaleNormal(10, 1, bounds=(10**6, 10**14), transformation=\"log10\"))\n" |
162 | | - ], |
| 163 | + "source": "plot(Normal(10, 1, bounds=(6, 14), transformation=\"log10\"))", |
163 | 164 | "id": "581e1ac431860419", |
164 | 165 | "outputs": [], |
165 | 166 | "execution_count": null |
166 | 167 | }, |
167 | 168 | { |
168 | 169 | "metadata": {}, |
169 | 170 | "cell_type": "code", |
170 | | - "source": "", |
| 171 | + "source": "plot(ParameterScaleNormal(10, 1, bounds=(10**6, 10**14), transformation=\"log10\"))", |
| 172 | + "id": "99202ecb47706a68", |
| 173 | + "outputs": [], |
| 174 | + "execution_count": null |
| 175 | + }, |
| 176 | + { |
| 177 | + "metadata": {}, |
| 178 | + "cell_type": "code", |
| 179 | + "source": "plot(LogLaplace(1, 0.5, bounds=(0.5, 8)))", |
171 | 180 | "id": "802a64be56a6c94f", |
172 | 181 | "outputs": [], |
173 | 182 | "execution_count": null |
| 183 | + }, |
| 184 | + { |
| 185 | + "metadata": {}, |
| 186 | + "cell_type": "code", |
| 187 | + "source": "plot(LogNormal(2, 1, bounds=(0.5, 8)))", |
| 188 | + "id": "7820e93ab9b2fb47", |
| 189 | + "outputs": [], |
| 190 | + "execution_count": null |
174 | 191 | } |
175 | 192 | ], |
176 | 193 | "metadata": { |
|
0 commit comments