fn pv_simulation_function(time_of_day: NaiveTime) -> f64 {
    let time_of_day_in_h = normalised_time_of_day(time_of_day);
    // Dusk and dawn in hours from midnight.
    // These values should be supplied by some external source
    // but are defined in this function for briefty.
    let dusk = 21.0;
    let dawn = 5.0;
    if time_of_day_in_h > dawn && time_of_day_in_h < dusk {
        // Scale the daytime to an interval from 0 to 1, where the
        // Kumaraswamy distribution is defined.
        let x = (time_of_day_in_h - dawn) / (dusk - dawn);
        // Scale the output to the expected power in watt.
        let scaling = 1650.0;
        // The parameters a and b were roughly approximated according to
        // the diagram supplied in the exercise description.
        let simulated_output = kumaraswamy_pdf(2.8, 3.3, x) * scaling;
        // Add some random noise to the simulated data.
        let jitter = thread_rng().gen_range(0.99, 1.01);
        simulated_output * jitter
    } else {
        // Return no power output while the sun is not out.
        0.0
    }
}
/// Simulates the power output of a photovoltaic component in watt by rough approximation with a
/// Kumaraswamy distribution.
///
/// # Parameters
///
/// * `time_of_day` - the time of day in nanosecond precision
Simulates the power output of a photovoltaic component in watt by rough approximation with a
Kumaraswamy distribution.
Simulates the power output of a photovoltaic component in watt by rough approximation with a Kumaraswamy distribution .
fn pv_simulation_function(time_of_day: NaiveTime) -> f64 {
    let time_of_day_in_h = normalised_time_of_day(time_of_day);
    // Dusk and dawn in hours from midnight.
    // These values should be supplied by some external source
    // but are defined in this function for briefty.
    let dusk = 21.0;
    let dawn = 5.0;
    if time_of_day_in_h > dawn && time_of_day_in_h < dusk {
        // Scale the daytime to an interval from 0 to 1, where the
        // Kumaraswamy distribution is defined.
        let x = (time_of_day_in_h - dawn) / (dusk - dawn);
        // Scale the output to the expected power in watt.
        let scaling = 1650.0;
        // The parameters a and b were roughly approximated according to
        // the diagram supplied in the exercise description.
        let simulated_output = kumaraswamy_pdf(2.8, 3.3, x) * scaling;
        // Add some random noise to the simulated data.
        let jitter = thread_rng().gen_range(0.99, 1.01);
        simulated_output * jitter
    } else {
        // Return no power output while the sun is not out.
        0.0
    }
}
fn pv_simulation_function ( time_of_day : NaiveTime ) -> f64 { let time_of_day_in_h = normalised_time_of_day ( time_of_day ) ; // Dusk and dawn in hours from midnight. // These values should be supplied by some external source // but are defined in this function for briefty. let dusk = 21.0 ; let dawn = 5.0 ; if time_of_day_in_h > dawn && time_of_day_in_h < dusk { // Scale the daytime to an interval from 0 to 1, where the // Kumaraswamy distribution is defined. let x = ( time_of_day_in_h - dawn ) / ( dusk - dawn ) ; // Scale the output to the expected power in watt. let scaling = 1650.0 ; // The parameters a and b were roughly approximated according to // the diagram supplied in the exercise description. let simulated_output = kumaraswamy_pdf ( 2.8 , 3.3 , x ) * scaling ; // Add some random noise to the simulated data. let jitter = thread_rng ( ) . gen_range ( 0.99 , 1.01 ) ; simulated_output * jitter } else { // Return no power output while the sun is not out. 0.0 } }
Simulates the power output of a photovoltaic component in watt by rough approximation with a
Kumaraswamy distribution.
Simulates the power output of a photovoltaic component in watt by rough approximation with a Kumaraswamy distribution .
time_of_day
NaiveTime
time_of_day
NaiveTime