# Voting Bot update: you can now pay to vote sooner

I've finally implemented a system which will allow my voting clients to pay for a good position in the voting order. The algorithm isn't perfectly simple, but I believe it's a good balance between fairness (for my clients) and profitability (for me).

## Part 1: Payment Ratio

My algorithm assigns each account a `payment_ratio`

, which is a ratio of the time-weighted sum of payments I've received from a client and the time-weighted sum of curation rewards they've received. It is something like the fraction of curation rewards paid by a client, but it counts recent payments and rewards more strongly than not-so-recent payments and rewards. The formula for `payment_ratio`

is this:

Where

- P is the set of all payments made by the client in the past 4 weeks
- pi is a payment
- ti is the time since payment pi was made
- T is the decay half-life, currently set to 1 week
- R is the set of all curation rewards earned by the client in the past 4 weeks
- rj is a curation reward
- tj is the time since curation reward rj was earned

So: we add up all payments made in the past 4 weeks, weighting them so that a payment made just now is counted for its full face value, a payment made 1 week ago is half its face value, 2 weeks ago is a quarter its face value, and so on.

Then, we add up all curation rewards in exactly the same way, with exactly the same weighting mechanic.

We divide the weighted sum of payments by the weighted sum of rewards, and that's the payment ratio. If you've regularly been paying 10% of your curation rewards to me, your payment ratio should be close to 10%.

## Part 2: Voting Order

Let's say I have *n* voting accounts, and the payment ratio of account *i* is *qi*. For each account *i*, I calculate a weight *wi* by the following formula:

I'm using T=0.01. The lower the parameter *T*, the more differentiated the accounts are by their payments. Then I normalize everybody's weight by the sum of the weights to calculate a probability for each account:

I vote account *i* first with probability *pi* as calculated above. The higher your payment ratio, the higher your probability of voting first.

After the first voter is selected, I repeat the process with the first voter removed; so the next-highest weight has the highest probability of voting second, and so on.

## Example

Suppose there are 5 accounts, and their payment ratios are

- Alice: 0.10
- Bob: 0.051
- Claire: 0.05
- Dave: 0.00
- Ella: 0.00

So Alice is paying me about 10% of her curation rewards, Bob and Claire are paying about 5% (but Bob pays a bit more), and Dave and Ella aren't paying anything. Ideally, we'd like Alice to vote first most of the time, Bob and Claire to vote about the same amount as each other, and Dave and Ella to vote last.

With T=0.01, the probabilities of voting first are as follows:

- Alice: 0.986
- Bob: 0.007
- Claire: 0.007
- Dave: 0.000
- Ella: 0.000

So in every 1000 votes, Alice will vote first for about 986 of those; Bob and Claire will each vote first about 7 times, and Dave and Ella practically never.

(Dave and Ella actually do have nonzero probability of going first; but they'll only vote first once every 20,000 votes.)

Now suppose Alice votes first, we have the following truncated list of payment ratios:

- Bob: 0.051
- Claire: 0.05
- Dave: 0.00
- Ella: 0.00

Run them through the probability formula again, and we get

- Bob: 0.522
- Claire: 0.472
- Dave: 0.003
- Ella: 0.003

Now, Bob has a slightly higher chance than Claire of voting second; this is because he's paying a little more. Notice that the more he pays, the further ahead of Claire he gets in the ranking.

Most likely, Bob and Claire vote next; then we're left with Dave and Ella, who get the last voting place each 50% of the time.

## How much should clients pay?

The voting-order algorithm is designed to be fair to everybody. If you pay more, you vote sooner on average. It's meant to be that simple; everybody gets something for everything they pay. Obviously, my clients will need to know where they sit in the rankings to be able to decide whether or not to pay more.

To that end, every day, I'll have my @ozymandias account post the current payment ratio rankings. If you see yourself lower in the rankings, you simply need to make a payment and that will bump you higher. Every payment you send to @biophil counts towards the payment ratio.

## What if I need to pay from my poloniex or bittrex account?

Contact me and I'll give you a unique memo to include in your transactions so that they get credited to the correct account.

theodosis63 (57)6 years agonice post :)

steemvest17 (68)6 years agoYou make me crazy with your formula. :D

That's cool my friend.

robrigo (66)6 years agoHey Phil! Do you accept SD?

biophil (66)6 years agoSure do! If you pay in SBD, I record its Steem value at the time it goes into my database.

biophil (66)6 years agoTest

biophil (66)6 years agoTest