UNPKG

@progress/kendo-angular-schematics

Version:

Kendo UI Schematics for Angular

94 lines (78 loc) 3.21 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ // The following source code is copied from https://github.com/d3fc/d3fc // The MIT License (MIT) // Copyright (c) 2015-2019 Scott Logic Ltd. // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // const { randomNormal } = require('d3-random'); const randomNormal = require('./randomNormal'); module.exports = function() { let period = 1; let steps = 20; let mu = 0.1; let sigma = 0.1; let random = randomNormal(); var geometricBrownianMotion = (value = 0) => { const timeStep = period / steps; const pathData = []; for (let i = 0; i < steps + 1; i++) { pathData.push(value); const increment = (random() * Math.sqrt(timeStep) * sigma) + ((mu - sigma * sigma / 2) * timeStep); value = value * Math.exp(increment); } return pathData; }; geometricBrownianMotion.period = (...args) => { if (!args.length) { return period; } period = args[0]; return geometricBrownianMotion; }; geometricBrownianMotion.steps = (...args) => { if (!args.length) { return steps; } steps = args[0]; return geometricBrownianMotion; }; geometricBrownianMotion.mu = (...args) => { if (!args.length) { return mu; } mu = args[0]; return geometricBrownianMotion; }; geometricBrownianMotion.sigma = (...args) => { if (!args.length) { return sigma; } sigma = args[0]; return geometricBrownianMotion; }; geometricBrownianMotion.random = (...args) => { if (!args.length) { return random; } random = args[0]; return geometricBrownianMotion; }; return geometricBrownianMotion; }