Skip to content

Commit 270208e

Browse files
authored
Merge pull request #322 from synthetichealth/exp_dist
Support exponential distribution.
2 parents b3a8cab + c10c87e commit 270208e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/components/editor/State.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ class Distribution extends Component<Distro> {
244244
return <Gaussian {...this.props} onChange={this.props.onChange} />
245245
case "UNIFORM":
246246
return <Uniform {...this.props} onChange={this.props.onChange} />
247+
case "EXPONENTIAL":
248+
return <Exponential {...this.props} onChange={this.props.onChange} />
247249
}
248250
}
249251
}
@@ -258,6 +260,8 @@ class Exact extends Component<Distro> {
258260
<br />
259261
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'GAUSSIAN'}}); this.props.onChange('parameters')({val: {id: {mean: 10, standardDeviation: 1}}})}}>Change to Gaussian</a>
260262
<br />
263+
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXPONENTIAL'}}); this.props.onChange('parameters')({val: {id: {mean: 10}}})}}>Change to Exponential</a>
264+
<br />
261265
{this.props.otherToggles}
262266
</div>
263267
);
@@ -279,6 +283,8 @@ class Uniform extends Component<Distro> {
279283
<br />
280284
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'GAUSSIAN'}}); this.props.onChange('parameters')({val: {id: {mean: 10, standardDeviation: 1}}})}}>Change to Gaussian</a>
281285
<br />
286+
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXPONENTIAL'}}); this.props.onChange('parameters')({val: {id: {mean: 10}}})}}>Change to Exponential</a>
287+
<br />
282288
{this.props.otherToggles}
283289
</div>
284290
);
@@ -300,12 +306,34 @@ class Gaussian extends Component<Distro> {
300306
<br />
301307
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'UNIFORM'}}); this.props.onChange('parameters')({val: {id: {high: 20, low: 10}}})}}>Change to Range</a>
302308
<br />
309+
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXPONENTIAL'}}); this.props.onChange('parameters')({val: {id: {mean: 10}}})}}>Change to Exponential</a>
310+
<br />
303311
{this.props.otherToggles}
304312
</div>
305313
);
306314
}
307315
}
308316
317+
class Exponential extends Component<Distro> {
318+
render() {
319+
return (
320+
<div>
321+
Mean: <RIENumber className='editable-text' value={this.props.parameters.mean} propName='mean' change={this.props.onChange('parameters.mean')} />
322+
<br />
323+
{this.props.round!=null &&
324+
<div>Round Result: <RIEToggle value={this.props.round} propName='round' change={this.props.onChange('round')} />
325+
<br /></div> }
326+
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXACT'}}); this.props.onChange('parameters')({val: {id: {value: 10}}})}}>Change to Exact</a>
327+
<br />
328+
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'UNIFORM'}}); this.props.onChange('parameters')({val: {id: {high: 20, low: 10}}})}}>Change to Range</a>
329+
<br />
330+
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'GAUSSIAN'}}); this.props.onChange('parameters')({val: {id: {mean: 10, standardDeviation: 1}}})}}>Change to Gaussian</a>
331+
<br />
332+
{this.props.otherToggles}
333+
</div>
334+
);
335+
}
336+
}
309337
310338
class Delay extends Component<Props> {
311339

src/utils/graphviz.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ const distributionString = (distro) => {
259259
return `${distro['parameters']['low']} - ${distro['parameters']['high']}`;
260260
case 'GAUSSIAN':
261261
return `Mean: ${distro['parameters']['mean']}, SD: ${distro['parameters']['standardDeviation']}`
262+
case 'EXPONENTIAL':
263+
return `Mean: ${distro['parameters']['mean']}`
262264
}
263265
return '';
264266
}

0 commit comments

Comments
 (0)