@@ -114,30 +114,61 @@ fn validate_inputs(parameters: &Params) -> Result<(), IxaError> {
114114 }
115115
116116 // Validate the symptom status parameters
117- if !( 0.0 ..=1.0 ) . contains ( & parameters. probability_mild_given_infect ) {
118- return Err ( IxaError :: IxaError (
119- "The probability of mild illness given infection must be between 0 and 1, inclusive."
120- . to_string ( ) ,
121- ) ) ;
122- }
123117
124- if !( 0.0 ..=1.0 ) . contains ( & parameters. probability_severe_given_mild ) {
125- return Err ( IxaError :: IxaError (
126- "The probability of severe illness given mild illness must be between 0 and 1, inclusive." . to_string ( ) ,
127- ) ) ;
128- }
118+ let probability_params = [
119+ (
120+ "probability_mild_given_infect" ,
121+ & parameters. probability_mild_given_infect ,
122+ ) ,
123+ (
124+ "probability_severe_given_mild" ,
125+ & parameters. probability_severe_given_mild ,
126+ ) ,
127+ (
128+ "probability_critical_given_severe" ,
129+ & parameters. probability_critical_given_severe ,
130+ ) ,
131+ (
132+ "probability_dead_given_critical" ,
133+ & parameters. probability_dead_given_critical ,
134+ ) ,
135+ ] ;
129136
130- if !( 0.0 ..=1.0 ) . contains ( & parameters. probability_critical_given_severe ) {
131- return Err ( IxaError :: IxaError (
132- "The probability of critical illness given severe illness must be between 0 and 1, inclusive." . to_string ( ) ,
133- ) ) ;
137+ for ( param_name, param_value) in probability_params {
138+ if !( 0.0 ..=1.0 ) . contains ( param_value) {
139+ return Err ( IxaError :: IxaError ( format ! (
140+ "{} = {} is not a valid transition probability; probabilities must be between 0 and 1, inclusive." ,
141+ param_name, param_value
142+ ) ) ) ;
143+ }
134144 }
135145
136- if !( 0.0 ..=1.0 ) . contains ( & parameters. probability_dead_given_critical ) {
137- return Err ( IxaError :: IxaError (
138- "The probability of dying given critical illness must be between 0 and 1, inclusive."
139- . to_string ( ) ,
140- ) ) ;
146+ let sigma_params = [
147+ ( "infect_to_mild_sigma" , & parameters. infect_to_mild_sigma ) ,
148+ ( "mild_to_severe_sigma" , & parameters. mild_to_severe_sigma ) ,
149+ ( "mild_to_resolved_sigma" , & parameters. mild_to_resolved_sigma ) ,
150+ (
151+ "severe_to_critical_sigma" ,
152+ & parameters. severe_to_critical_sigma ,
153+ ) ,
154+ (
155+ "severe_to_resolved_sigma" ,
156+ & parameters. severe_to_resolved_sigma ,
157+ ) ,
158+ ( "critical_to_dead_sigma" , & parameters. critical_to_dead_sigma ) ,
159+ (
160+ "critical_to_resolved_sigma" ,
161+ & parameters. critical_to_resolved_sigma ,
162+ ) ,
163+ ] ;
164+
165+ for ( param_name, param_value) in sigma_params {
166+ if param_value < & 0.0 {
167+ return Err ( IxaError :: IxaError ( format ! (
168+ "{} = {} is not a valid value for sigma; log normal distribution sigmas must be non-negative." ,
169+ param_name, param_value
170+ ) ) ) ;
171+ }
141172 }
142173
143174 // We only want to fail when all itinerary ratios are 0.
0 commit comments