Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding functions to stats.js #3

Merged
merged 2 commits into from
Jul 5, 2023
Merged

Conversation

riya-patil
Copy link
Contributor

@riya-patil riya-patil commented Jul 1, 2023

Description

The following functions have been added to stats.js:

  • Mean/STD simulation
  • Monte Carlo Simulation
  • Vegas Simulation
  • Autocorrelation function
  • Autocovariance Matrix
  • Gaussian distribution
  • Bernoulli Distribution
  • Generalized Extreme Value (GEV)
    Note: Autocovariance Matrix is incomplete

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Chrome browser testing: using Inspect element, I used the console to test all the functions I'm implementing by making an instance of HydroLang and calling the function for a result.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

The following functions have been added to stats.js:
- Mean/STD simulation
- Monte Carlo Simulation
- Vegas Simulation
- Autocorrelation function
- Autocovariance Matrix
- Gaussian distribution
- Bernoulli Distribution
- Generalized Extreme Value (GEV)
Note: Autocovariance Matrix is incomplete
Copy link
Collaborator

@erazocar erazocar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General

  • Move distributions and simulators to the space before the helper functions.
  • Attach your attribution using the @author nametag to the comments.
  • Where possible and to avoid errors during execution, create default values a function can fall to in case some parameter is not met. If done, mention in the function documentation. Example:
static autocorrelation({ params, args, data } = {}) {
  const { lag } = params || 2;
//...
  • Use naming conventions inferred from the context of the function (e.g. simulatedValue instead of myVar)

Run Simulation functions
Merge the two runSimulation functions together and generalize it more using the params object to define what is required.

Example:

  static runSimulation({params, args, data} = {}) {
   // grabs multiplier from params or defaults to 1
   const { multiplier } = params || 1;
   //...
    const simNum = genRan(mean - std * multiplier, mean + std * multiplier);
    return simNum
}

Monte Carlo and Las Vegas
The functions should run on a 1-d dataset bounded by n-iterations. The iterations can be default to 100 or passed by the user. Allow a callback function to be passed either in the params or args space so we can fit a model like ARIMA, ARMA, or others as part of the function and create a proper simulation.

Example:

static runMonteCarlo({params, args, data} = {}) {
    const { simulations } = params || 100;
   const { callback } = params.callback || null;
   //...
    for (let i = 0; i < num_simulations; i++) {
        const simResult;
        //run a callback function if exists, return random sample of doesnt.
        if (callback) simResult = callback({//...implementation details here})
        else { simResult = this.runSimulation({data : value}) }
        results.push(simResult)
    }
    return results;
 }

Autocorrelation functions
These can also be merged. You can use the autocorrelation function inside the autocovariance matrix.

@erazocar erazocar merged commit 73ef27f into uihilab:master Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants