How to forecast a future value?

Asked

Viewed 706 times

0

I’m making a calculator for games FPS, and in it, you enter the number of Kills, and the number of Deaths. So far so good, I was able to do the command line so she could take the two values, and set the percentage, but at forecast time I get lost. I’m starting now with programming C# and I don’t know what to wear.

int kill, death;
double valor, KD_Porcentagem; 

valor = kill + death; //É SOMADO OS VALORES TOTAIS  
KD_Porcentagem = (kill * 100) / valor;//MULTIPLICADO O REQUERIDO POR 100, E DIVIDIDO PELA SOMA

Simple, I simply made rule of three, stating that the value is equal to 100% and that Kill is equal to Kd_percentage. I tried to do the same, but it didn’t work. Get me a calculator with the same scheme, and same idea, in which happens the following:

For Kill = 90

and death = 30

Kd_percentage = 75%

In the forecast, the following occurs :

Forecasting:

Kill/Death 76%: Kill less Death in the period has to be: 3

Kill/Death 77%: Kill less Death in the period has to be: 8

Kill/Death 78%: Kill less Death in the period has to be: 14

Kill/Death 79%: Kill less Death in the period has to be: 20

I’ve tried everything already, but I can’t think of anything... could help?

  • 3

    What kind of forecast do you want to make? Weather Forecast (Hehe)? Try to explain better what you want and what problem you are facing in trying to solve it, so we can help you.

  • 2

    I want to predict the number, which added to Kill increases the percentage, remembering that it can be any number in a range between (int Kd_percentage) + 0.5 and (int Kd_percentage) + 1.0, in case, if the whole percentage is 75, I could take any number between 75.5 and 76, because the number will be rounded whenever it reaches one of these values. Do you understand? xD

  • 4

    "lembrando que pode ser qualquer número em um intervalo usando aquela fórmula que eu nunca mencionei antes..." No. No one here knows the variables of your program or the rules of business. It’s okay to edit the question to contain more information and make it clearer, okay? Help us understand the problem and we will help you solve it ;)

  • 1

    Please use the option edit of your question, and pass on the information necessary so that a person/programmer who is NOT on your side looking at your source code and seeing your finger being pointed at the problem can understand your problem and maybe (depending on the weather forecast) can help you.

  • It’s not clear yet...

  • You have a wrong logic. If the player has 90 Kills, and 30 Deaths, his K/D is 3, can’t be 75% since it is Kill/Death... You have to see this

Show 1 more comment

2 answers

1

Daniloloko’s answer is correct, but I think it could simplify.

The answer goes down for predictions in the next 5 percentages. by mathematics

PARA AUMENTAR EM UM A PORCENTAGEM É NECESSÁRIO
100(X+killinicial)/killinicial+deathinicial+X = porcentagem+1
100x+100killinicial/valorinicial+x=porcentagem+1
100x+100killinicial=(valorinicial+x)(porcentagem+1)
100x+100killinicial=valorinicial*(porcentagem+1)+x*(porcentagem+1)
100x-x*(porcentagem+1)=valorinicial*(porcentagem+1)-100killinicial
x=(valorinicial*(porcentagem+1)-100killinicial)/(100-porcentagem+1)

your code

    int kill, death,x;
double valor, KD_Porcentagem; 

valor = kill + death; //É SOMADO OS VALORES TOTAIS  
KD_Porcentagem = (kill * 100) / valor;//MULTIPLICADO O REQUERIDO POR 100, E DIVIDIDO PELA SOMA
KD_porcentagem = KD_Porcentagem % 100// PEGA SÓ A PARTE INTEIRA. FACILITANDO NOSSA VIDA.
x=((valor*(KD_Porcentagem+1))-100*kill)/(100-KD_Porcentage+1)

in your example you had:

For Kill = 90

and death = 30

Kd_percentage = 75%

value: 120

by my formula

x = (120*76)-9000/24 x = 5

which shows that your example is wrong because: in this new example we have k-95 D-30 value 125 9500/125=76%

By completing your code you do a for as many times as you want and only reassign the values. if you do not want to lose the values of Kill and death use Variable backup.

your code with the 5 exits:

        int kill, death,x;
double valor, KD_Porcentagem; 


valor = kill + death; //É SOMADO OS VALORES TOTAIS  
KD_Porcentagem = (kill * 100) / valor;//MULTIPLICADO O REQUERIDO POR 100, E DIVIDIDO PELA SOMA
//mostra a porcentagem atual com kill death.

//faz a previsão
for(int y=0;y<5;y++)
{
   valor = kill + death; //É SOMADO OS VALORES TOTAIS  
   KD_Porcentagem = (kill * 100) / valor;//MULTIPLICADO O REQUERIDO POR 100, E DIVIDIDO PELA SOMA
   KD_porcentagem = KD_Porcentagem % 100// PEGA SÓ A PARTE INTEIRA. FACILITANDO NOSSA VIDA.
   x=((valor*(KD_Porcentagem+1))-100*kill)/(100-KD_Porcentage+1);
   //mostra x
   kill=kill+x;
}
  • can format your code and texts better so that it is easier to understand?

1

Nothing that lists and rule of 3 won’t solve... our math friend will help us in this...

You can do it in various ways... average or sum of the daily Kills/Deaths... and make a projection of these values before a base (games won/hours played/%improvement per game)... Oh yes You can have a forecast being it increasing or decreasing.

If it is a game that wins XP/Level... it would be even more interesting... because Voce would inform the current value of Xp gain... and it will make a projectile when Voce reach a certain level.

I’d do it this way...

//criando nossa classe de dados
public class Dado
{
  Datetime datahora { get; set; }
  int kills { get; set; }
  int deaths { get; set; }
}

//criando uma lista desses dados...
//apos inserir varias essa lista contera varios dados... entao voce pode começar a brincar com eles... com alguns foreachs e if...

//instanciando a lista
List<Dado> ListaDados = new List<Dado>();

//instanciando um dado
Dado d = new Dado();
d.datahora = DateTime.Now();
d.kills = 120;
d.deaths = 60;

//adicionando o dado na lista...
ListaDados.Add(d);

Now your list has a given... You can show this list in a Datagridview (using windows Forms)...

DGV.DataSource = ListaDados.ToList();

And we can walk on that list and do some math math... like a K average for example...

int totalelementoslista = ListaDados.Count;
int killstotais = 0;
int mortestotais = 0;
foreach (Dado d in ListaDados)//percorrendo a lista de dados
{
    killstotais += d.kills;
    mortestotais += d.deaths;
    int mediakillsdessejogo = d.kills / d.deaths; //ai voce guarda em algum outro lugar se quiser
}

    int mediakills = killstotais / mortestotais; // voce tem a media de kills de todos os jogos juntos.

UPDATE: You explained a little about your need... it would be to create a future projection of Kills/Aths relative to a percentage... and this is very easy to do... Create a new data list... and generate it using a for... generating values in this list using mathematics. ai Voce will have the data inside... everything straight there Voce can put even on a curve chart... and will be fine show!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.