コード例 #1
0
def get_results_from_scratch(sample_size, nr_samples, sample_type, xi, rejection_prob, save_hill_estimation = False):
    start_time = time.time()
    # Sampling
    print(f'Started sampling {nr_samples} samples of {sample_size} {sample_type}')
    sample_file = Sampling.Sampler(xi, sample_type).sample_to_file(sample_size, nr_samples)
    end_sampling = time.time()
    print(f'Finished sampling in {round(end_sampling - start_time, 2)} seconds')
    if save_hill_estimation:
        # Hill estimation
        print('Started writing hill estimator to file')
        hills_file = Hill.hills_from_sample_to_file(sample_file)
        end_hill = time.time()
        print(f'Finished writing hill estimator to file in {round(end_hill - end_sampling,2)} seconds')
    # Measurement execution
    print('Started measuring')
    start_measuring = time.time()
    Measuring.Measuring(sample_file, rejection_prob).writing_results_to_files()
    end_measuring = time.time()
    print(f'Finished measuring in {round(end_measuring - start_measuring,2)} seconds')
    print(f'Total run time {round(end_measuring - start_time,2)} seconds \n which is {round((end_measuring - start_time)/60)} minutes')
    return sample_file
コード例 #2
0
def get_results_from_noise(sample_file, noise_type, rejection_prob, save_hill_estimation=False, **kwargs):
    start_time = time.time()
    # manipulation
    manipulator = Manipulation.SampleManipulation(sample_file, noise_type, kwargs)
    print(f'Started adding {noise_type} noise')
    sample_with_noise_file = manipulator.add_noise_from_file()
    end_adding_noise = time.time()
    print(f'Finished adding noise in {round(end_adding_noise - start_time, 2)} seconds')
    if save_hill_estimation:
        # Hill estimation
        print('Started writing Hill estimator to file')
        hills_file = Hill.hills_from_sample_to_file(sample_with_noise_file)
        end_hill = time.time()
        print(f'Finished writing hill estimator to file in {round(end_hill - end_adding_noise, 2)} seconds')
    # Measurement execution
    start_measuring = time.time()
    print('Started measuring')
    Measuring.Measuring(sample_with_noise_file, rejection_prob).writing_results_to_files()
    end_measuring = time.time()
    print(f'Finished measuring in {round(end_measuring - start_measuring, 2)} seconds')
    print(f'Total run time {round(end_measuring - start_time, 2)} seconds '
          f'\n which is {round((end_measuring - start_time) / 60)} minutes')