I read lots of articles, but i really confused about it. it read that is background for calculating AverageTimer32 the system use this formula: ((N1 - N0) / F) / (B1 - B0)
I searched about t this formula i find that:
N1 current reading at time t (provided to the AverageTimer32/64)
N0 reading before, at t – 1 (provided to the AverageTimer32/64)
B1 current counter at t (provided to the AverageBase)
B0 counter before, at t – 1 (provided to the AverageBase)
F Factor to calculate ticks/seconds
the questions:
1-what F and HOW It was calculated? or where is it come from?
2-As the above was said N0 reading before, at t – 1 , what is t-1 ? so if the current time is 01:14:44 how can i get t-1? it talk about second?
3- according to the this formula the AverageTime doesnot give a total average. for example if method A was called 4 times and its takes times in sec (in order): 2 sec , 4 sec, 3 sec , 2 sec, i assume it give us average times like this =>(2+4+3+2)/4 , and if the fifth called take 3 sec so : it give (2+4+3+2+3)/5, but it does not do like this?
and if its possible please explain more about about AverageTimer32 formula.
thanks in adv
Related
I have data like that:
Time(seconds from start)
Value
15
2
16
4
19
2
25
9
There are a lot of entries (10000+), and I need a way to find fast enough sum of any time range, like sum of range 16-25 seconds (which would be 4+2+9=15). This data will be dynamically changed many times (always adding new entries at the bottom of list).
I am thinking about using sorted list + binary search to determinate positions and just make sum of values, but is can took too much time to calculate it. Is there are any more appropriate way to do so? Nuget packets or algorithm references would be appreciated.
Just calculate cumulative sum:
Time Value CumulativeSum
15 2 2
16 4 6
19 2 8
25 9 17
Then for range [16,25] it will be task to binary search left border of 16 and 25 exact, which turns into 17 - 2 = 15
Complexity: O(log(n)), where n - size of the list.
Binary search implementation for lower/upper bound can be found in my repo - https://github.com/eocron/Algorithm/blob/master/Algorithm/Sorted/BinarySearchExtensions.cs
Disclaimer: This is not a class project, more of work related. I tried finding example online but generally its just for transversing through the tree. I am coding it in C#
Hi all,
I am trying to use DFS to calculate the biggest possible number sum combination which will be equal to the number given with some other conditions.
Total sum of weight needs to be below 150 in a class.
Total height in the class cannot be more than 600.
Max number of student if possible in Class A
If same height and weight, the person with the smaller ID will be considered first.
ID - Weight - Height
1 - 80 - 150
2 - 30 - 100
3 - 30 - 150
4 - 50 - 100
5 - 60 - 150
6 - 40 - 100
Class 1: 1, 2, 6
Class 2: 3, 4, 5
Class 3:
Anyone can point me in the right direction or DFS shouldn't be used in this case?
DFS and BFS works with trees, which you currently do not have. IMO, creating a tree with all possible combinations is not the right way in this case (but of course you can do it). If your set is small you can try to enumerate all solutions without creating a tree and using DFS or BFS (as #Dennis.Verweij is proposing).
I think that your problem is a variation of the Knapsack problem, which is unfortunately NP-Complete
Otherwise take a look at Integer Programming. This is a hard problem to solve, but you can find some relevant algorithms (which might actually use internally DFS) to help you with the solution.
I have seen posts on how to define a specific time but couldn't find on discrepancy issues. Hope someone can enlighten me.
I want to define a schedule time as let's say 11.10 a.m in windows service. I have my code like this.
scheduledDailyRun = DateTime.Today.AddHours(11.10); // testing
eventLog1.WriteEntry("Scheduled defined # " + scheduledDailyRun.ToString()); //<<--DEBUG
When I check eventlog1, it says "Scheduled defined # 26/11/2013 11:06:00 AM". Why is it not 11.10 which is defined up there as DateTime.Today.AddHours(11.10)?
.10 = 10%
10% of 1 hour (60 minutes) = 6 minutes.
11.06 is correct.
Use .AddHours(11).AddMinutes(10); instead
To add 11 hrs 10 min, use following
DateTime.Today.AddHours(11).AddMinutes(10);
let´s say i have a base 10 dB and then i increment this value to 16 dB, there are 6 dB of diference so my volume has changed, but now let´s say i want to increment the same amout of volume to a different value of base dB, for instance i have 50 dB now and i want to add the same amount of volume that i added before, well certanly it isn´t 56dB what i will end up with, i know it's a logarithmic equation.
My question is if there is a formula to find out how much volume i have to increment any time based on a previous amount of volume change?
notes:
1)my volume control goes from 0 to 1
2)i don't just increment te volume and forget the rest because i need to make the sound change it's volume dynamically while it is being played
Sound like you're looking for 'Percent Change'.
((y2 - y1) / y1) = percentage change
((16-10)/10) = 0.6
http://www.percent-change.com/index.php?y1=10&y2=16
A Start: 10dB
A Finish: 16dB
A Delta: 6dB
A Percent Change = 0.6
B Start: 50dB
B Finish: (((A Finish - A Start) / A Start) * B Start) + B Start
(((16-10)/10)*50)+50 = 80
In your example the 50dB should be increased to 80dB.
I am looking now for some time about how can a programmer simulate a AI decision based on percentages of actions for the final fantasy tactic-like games (strategy game).
Say for example that the AI character has the following actions:
Attack 1: 10%
Attack 2: 9%
Magic : 4%
Move : 1%
All of this is far from equaling 100%
Now at first I though about having an array with 100 empty slots, attack would have 10 slots, attack 2 9 slots on the array. Combining random I could get the action to do then. My problem here is it is not really efficient, or doesn't seem to be. Also important thing, what do I do if I get on an empty slot. Do I have to calculate for each character all actions based on 100% or define maybe a "default" action for everyone ?
Or maybe there is a more efficient way to see all of this ? I think that percentage is the easiest way to implement an AI.
The best answer I can come up with is to make a list of all the possible moves you want the character to have, give each a relative value, then scale all of them to total 100%.
EDIT:
For example, here are three moves I have. I want attack and magic to be equally likely, and fleeing to be half as likely as attacking or using magic:
attack = 20
magic = 20
flee = 10
This adds up to 50, so dividing each by this total gives me a fractional value (multiply by 100 for percentage):
attack = 0.4
magic = 0.4
flee = 0.2
Then, I would make from this a list of cumulative values (i.e. each entry is a sum of that entry and all that came before it):
attack = 0.4
magic = 0.8
flee = 1
Now, generate a random number between 0 and 1 and find the first entry in the list that is greater than or equal to that number. That is the move you make.
No, you just create threshholds. One simple way is:
0 - 9 -> Attack1
10 - 18 -> Attack 2
19 - 22 -> Magic
23 -> Move
Something else -> 24-99 (you need to add up to 100)
Now create a random number and mod it by 100 (so num = randomNumber % 100) to define your action. The better the random number to close to a proper distribution you will get. So you take the result and see which category it falls into. You can actually make this even more efficient but it is a good start.
Well if they don't all add up to 100 they aren't really percentages. This doesnt matter though. you just need to figure out the relative probability of each action. To do this use the following formula...
prob = value_of_action / total_value_of_all_actions
This gives you a number between 0 and 1. if you really want a percentage rather than a fraction, multiply it by 100.
here is an example:
prob_attack = 10 / (10 + 9 + 4 + 1)
= 10 / 24
= 0.4167
This equates to attack being chosen 41.67% of the time.
you can then generate thresholds as is mentioned in other answers. And use a random number between 0 and 1 to choose your action.