def generate_values(self, *args, **kwargs):
        """
        Instantiate a random variable and apply annual growth factors.

        :return:
        """
        assert 'ref value' in self.kwargs

        # 1. Generate $\mu$
        start_date = self.times[0].to_pydatetime()
        end_date = self.times[-1].to_pydatetime()
        ref_date = self.ref_date

        mu = self.generate_mu(end_date, ref_date, start_date)

        # 3. Generate $\sigma$
        ## Prepare array with growth values $\sigma$
        if self.sample_mean_value:
            sigma = np.zeros((len(self.times), self.size))
        else:

            if self.kwargs['type'] == 'interp':

                def get_date(record):
                    return datetime.datetime.strptime(record[0], "%Y-%m-%d")

                ref_value_ = sorted(json.loads(self.kwargs['ref value'].strip()).items(), key=get_date)
                intial_value = ref_value_[0][1]
            else:
                intial_value = self.kwargs['ref value']

            variability_ = intial_value * self.kwargs['initial_value_proportional_variation']
            logger.debug(f'sampling random distribution with parameters -{variability_}, 0, {variability_}')
            sigma = np.random.triangular(-1 * variability_, 0, variability_,
                                         (len(self.times), self.size))
        ## 4. Prepare growth array for $\alpha_{sigma}$
        alpha_sigma = growth_coefficients(start_date,
                                          end_date,
                                          ref_date,
                                          self.kwargs['ef_growth_factor'], 1)

        ### 5. Prepare DataFrame
        iterables = [self.times, range(self.size)]
        index_names = ['time', 'samples']
        _multi_index = pd.MultiIndex.from_product(iterables, names=index_names)

        df = pd.DataFrame(index=_multi_index, dtype=float)

        from dateutil import relativedelta
        r = relativedelta.relativedelta(end_date, start_date)
        months = r.years * 12 + r.months + 1
        name = kwargs['name']
        ## Apply growth to $\sigma$ and add $\sigma$ to $\mu$
        df[name] = ((sigma * alpha_sigma) + mu.reshape(months, 1)).ravel()

        ## test if df has sub-zero values
        df_sigma__dropna = df[name].where(df[name] < 0).dropna()
        if not df_sigma__dropna.empty:
            logger.warning(f"Negative values for parameter {name} from {df_sigma__dropna.index[0][0]}")

        return df[name]
def generate_values ( self , * args , ** kwargs ) : assert 'ref value' in self . kwargs start_date = self . times [ 0 ] . to_pydatetime ( ) end_date = self . times [ - 1 ] . to_pydatetime ( ) ref_date = self . ref_date mu = self . generate_mu ( end_date , ref_date , start_date ) if self . sample_mean_value : sigma = np . zeros ( ( len ( self . times ) , self . size ) ) else : if self . kwargs [ 'type' ] == 'interp' : def get_date ( record ) : return datetime . datetime . strptime ( record [ 0 ] , "%Y-%m-%d" ) ref_value_ = sorted ( json . loads ( self . kwargs [ 'ref value' ] . strip ( ) ) . items ( ) , key = get_date ) intial_value = ref_value_ [ 0 ] [ 1 ] else : intial_value = self . kwargs [ 'ref value' ] variability_ = intial_value * self . kwargs [ 'initial_value_proportional_variation' ] logger . debug ( f'sampling random distribution with parameters -{variability_}, 0, {variability_}' ) sigma = np . random . triangular ( - 1 * variability_ , 0 , variability_ , ( len ( self . times ) , self . size ) ) alpha_sigma = growth_coefficients ( start_date , end_date , ref_date , self . kwargs [ 'ef_growth_factor' ] , 1 ) iterables = [ self . times , range ( self . size ) ] index_names = [ 'time' , 'samples' ] _multi_index = pd . MultiIndex . from_product ( iterables , names = index_names ) df = pd . DataFrame ( index = _multi_index , dtype = float ) from dateutil import relativedelta r = relativedelta . relativedelta ( end_date , start_date ) months = r . years * 12 + r . months + 1 name = kwargs [ 'name' ] df [ name ] = ( ( sigma * alpha_sigma ) + mu . reshape ( months , 1 ) ) . ravel ( ) df_sigma__dropna = df [ name ] . where ( df [ name ] < 0 ) . dropna ( ) if not df_sigma__dropna . empty : logger . warning ( f"Negative values for parameter {name} from {df_sigma__dropna.index[0][0]}" ) return df [ name ]
Instantiate a random variable and apply annual growth factors.

        :return: