MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ geometric_weights()

MAYAFLUX_API std::vector< double > MayaFlux::Kinesis::Discrete::geometric_weights ( size_t  count,
double  ratio,
bool  unit_sum = false 
)

Weights that fall by a constant ratio with age.

Takes the ratio and allows any sign. ramp_exponential in Transform is the same progression fixed by its two endpoints, positive only.

Parameters
countNumber of weights
ratioFactor between one weight and the next older one
unit_sumScale so the weights sum to 1
Returns
ratio^k for k = 0 .. count - 1, newest first

Definition at line 187 of file Coefficients.cpp.

188{
189 std::vector<double> weights(count);
190 double weight = 1.0;
191 double total = 0.0;
192 for (size_t k = 0; k < count; ++k) {
193 weights.at(k) = weight;
194 total += weight;
195 weight *= ratio;
196 }
197
198 if (unit_sum && std::abs(total) > 1e-12) {
199 for (double& w : weights)
200 w /= total;
201 }
202 return weights;
203}
uint32_t total
double weight
size_t count

References count, total, and weight.