All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.finmath.climate.models.dice.submodels.EvolutionOfCapital Maven / Gradle / Ivy

Go to download

finmath lib is a Mathematical Finance Library in Java. It provides algorithms and methodologies related to mathematical finance.

There is a newer version: 6.0.19
Show newest version
package net.finmath.climate.models.dice.submodels;

import java.util.function.BiFunction;
import java.util.function.Function;

import net.finmath.time.TimeDiscretization;

/**
 * the evolution of the capital (economy)
 * \(
 * 	K(t_{i+1}) = (1-delta) K(t_{i}) + investment
 * \)
 *
 * @author Christian Fries
 */
public class EvolutionOfCapital implements Function> {

	private final TimeDiscretization timeDiscretization;
	private final double capitalDeprecation;

	public EvolutionOfCapital(TimeDiscretization timeDiscretization, double capitalDeprecation) {
		super();
		this.timeDiscretization = timeDiscretization;
		this.capitalDeprecation = capitalDeprecation;
	}

	public EvolutionOfCapital(TimeDiscretization timeDiscretization) {
		// capital deprecation per 1 year: 5th root of (1-0.1) per 5 years
		this(timeDiscretization, -Math.log(1-0.1)/5.0);
	}

	@Override
	public BiFunction apply(Integer timeIndex) {
		double timeStep = timeDiscretization.getTimeStep(timeIndex);
		return (Double capital, Double investment) -> {
			return capital * Math.exp(-capitalDeprecation * timeStep) + investment * timeStep;
		};
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy