-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWalletBalanceGenerator.m
More file actions
38 lines (31 loc) · 1.5 KB
/
Copy pathWalletBalanceGenerator.m
File metadata and controls
38 lines (31 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
classdef WalletBalanceGenerator < handle
% This is the random wallet balance generator
% At every iteration of the simulation, one wallet is randomly
% chosen. The wallet is represented by a double indicating the token
% availability (this parameter is used to determine the maximum
% spending capacity of the user)
% An exponential distribution is used
properties
TotalTokenSupply double
Rate double % Rate parameter for exponential distribution
ExpDistribution % Exponential distribution
end
methods
function walletDistribution = WalletBalanceGenerator(totalFreeTokenSupply, rate)
% PARAMS
% total free token supply - double
% rate (for exponential distribution) - double
walletDistribution.TotalTokenSupply = totalFreeTokenSupply;
walletDistribution.Rate = rate;
walletDistribution.ExpDistribution = walletDistribution.computeExponentialDistribution();
end
function randomWalletBalance = rndWalletBalance(self)
% A wallet is randomly chosen
randomWalletBalance = random(self.ExpDistribution, 1, 1);
end
function distr = computeExponentialDistribution(self)
% Compute the exponential distribution with given rate
distr = makedist('Exponential', 'mu', 1/self.Rate);
end
end
end