Skip to content

Commit

Permalink
Merge pull request #322 from synthetichealth/exp_dist
Browse files Browse the repository at this point in the history
Support exponential distribution.
  • Loading branch information
hadleynet authored Jan 6, 2023
2 parents b3a8cab + c10c87e commit 270208e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/components/editor/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ class Distribution extends Component<Distro> {
return <Gaussian {...this.props} onChange={this.props.onChange} />
case "UNIFORM":
return <Uniform {...this.props} onChange={this.props.onChange} />
case "EXPONENTIAL":
return <Exponential {...this.props} onChange={this.props.onChange} />
}
}
}
Expand All @@ -258,6 +260,8 @@ class Exact extends Component<Distro> {
<br />
<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>
<br />
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXPONENTIAL'}}); this.props.onChange('parameters')({val: {id: {mean: 10}}})}}>Change to Exponential</a>
<br />
{this.props.otherToggles}
</div>
);
Expand All @@ -279,6 +283,8 @@ class Uniform extends Component<Distro> {
<br />
<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>
<br />
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXPONENTIAL'}}); this.props.onChange('parameters')({val: {id: {mean: 10}}})}}>Change to Exponential</a>
<br />
{this.props.otherToggles}
</div>
);
Expand All @@ -300,12 +306,34 @@ class Gaussian extends Component<Distro> {
<br />
<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>
<br />
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXPONENTIAL'}}); this.props.onChange('parameters')({val: {id: {mean: 10}}})}}>Change to Exponential</a>
<br />
{this.props.otherToggles}
</div>
);
}
}
class Exponential extends Component<Distro> {
render() {
return (
<div>
Mean: <RIENumber className='editable-text' value={this.props.parameters.mean} propName='mean' change={this.props.onChange('parameters.mean')} />
<br />
{this.props.round!=null &&
<div>Round Result: <RIEToggle value={this.props.round} propName='round' change={this.props.onChange('round')} />
<br /></div> }
<a className='editable-text' onClick={() => {this.props.onChange('kind')({val: {id: 'EXACT'}}); this.props.onChange('parameters')({val: {id: {value: 10}}})}}>Change to Exact</a>
<br />
<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>
<br />
<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>
<br />
{this.props.otherToggles}
</div>
);
}
}
class Delay extends Component<Props> {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/graphviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ const distributionString = (distro) => {
return `${distro['parameters']['low']} - ${distro['parameters']['high']}`;
case 'GAUSSIAN':
return `Mean: ${distro['parameters']['mean']}, SD: ${distro['parameters']['standardDeviation']}`
case 'EXPONENTIAL':
return `Mean: ${distro['parameters']['mean']}`
}
return '';
}
Expand Down

0 comments on commit 270208e

Please sign in to comment.