Skip to content

Commit cbc5c33

Browse files
author
minjk-bl
committed
Edit multinomial codes on ProbDist
1 parent 915d53b commit cbc5c33

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

visualpython/js/m_stats/ProbDist.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ define([
264264
code.appendLine("with warnings.catch_warnings():");
265265
code.appendLine(" warnings.simplefilter(action='ignore', category=Warning)");
266266
if (this.distList[0].child.includes(distType)) {
267-
code.appendFormatLine(" sns.countplot(x={0})", allocateTo);
267+
if (distType === 'multinomial') {
268+
code.appendFormatLine(" plt.boxplot(x={0})", allocateTo);
269+
} else {
270+
code.appendFormatLine(" sns.countplot(x={0})", allocateTo);
271+
}
268272
} else {
269273
code.appendFormatLine(" sns.histplot({0}, stat='density', kde=True)", allocateTo);
270274
}
@@ -291,15 +295,23 @@ define([
291295
code.appendLine("plt.xlabel('$x$')");
292296
code.appendLine("plt.ylabel('$p(x)$')");
293297
code.append("plt.show()");
294-
} else if (distType === 'binomial' || distType === 'multinomial') {
295-
let { n=10 } = this.state;
298+
} else if (distType === 'binomial') {
299+
var { n=10 } = this.state;
296300
code.appendFormatLine("plt.bar(range(0,{0}), _rv.pmf(range(0,{1})))", n, n);
297301
code.appendFormatLine("plt.title('Probability mass function: {0}')", label.replace("'", "\\'"));
298302
code.appendFormatLine("plt.xlim(-1, {0})", n);
299303
code.appendFormatLine("plt.xticks(range(0, {0}), ['x='+str(i) for i in range(0, {1})])", n, n);
300304
code.appendLine("plt.xlabel('$x$')");
301305
code.appendLine("plt.ylabel('$p(x)$')");
302306
code.append("plt.show()");
307+
} else if (distType === 'multinomial') {
308+
code.appendFormatLine("for i in range(0, {0}.shape[1]):", allocateTo);
309+
code.appendLine(" plt.subplot(2, 2, i+1)");
310+
code.appendLine(" plt.title('$x$=' + str(i))");
311+
code.appendFormatLine(" sns.countplot(x=[ x[i] for x in {0} ])", allocateTo);
312+
code.appendLine("plt.suptitle('Probability mass function: Multinomial')");
313+
code.appendLine("plt.tight_layout()");
314+
code.appendLine("plt.show()");
303315
}
304316
}
305317
} else {

0 commit comments

Comments
 (0)