Algorithm for Generating Percentage Amounts

  • Thread starter natedgreat3
  • Start date
  • Tags
    Algorithm
In summary, the conversation discusses the formulation of an algorithm for creating a pie chart with a certain number of wedges, where each wedge is a certain percentage bigger than the previous one and the total percentage adds up to 100. The solution involves using a geometric series and solving for the first wedge's size. Alternatively, one can start with a wedge size of 1 and scale up the sizes to reach a total of 100%.
  • #1
natedgreat3
3
0
Hey guys,

Not totally sure this thread belongs in this section, feel free to move.

I'm trying to formulate an algorithm for an unusual problem.

- Generate a pie chart with X number of wedges.
- Each wedge is X percentage bigger then the one before it.
- Percentage amounts of all wedges must add up to 100 (thereby completing the pie chart)

So for example, in Excel I can create a pie chart with 5 wedges, and each wedge is 20% bigger then the previous one. It gives me these numbers (rounded).

Wedge 1: 13.43797%
Wedge 2: 16.125564%
Wedge 3: 19.3506768%
Wedge 4: 23.22081216%
Wedge 5: 27.86497459%

But I got that result by trial and error of Wedge 1's value until the final output of the pie chart hit 100%. How do I calculate Wedge 1's value simply based off the number of wedges in the pie, and the percentage amounts from one wedge to the next?

I appreciate any help you guys can provide =]
 
Physics news on Phys.org
  • #3
Okay cool, except a geometric series doesn't have to add up to a maximum amount, in this case 100% =/
 
  • #4
That's where doing math comes in. If your starting wedge has a%, then you want
a + 1.2a + (1.2)2a + 1.23a + 1.24a = 100

Notice that 1.2 a is 20% larger than a, and 1.22a is 20% larger than 1.2a, etc. Now all you have to do is solve for a.
 
  • #5
If you don't like algebra, suppose the first wedge is size 1.
You then have 5 wedges with sizes 1, 1.2, 1.44, 1.728, 2.0736 which add up to 7.4416
So you need to scale up the sizes by 100 / 7.4416 = 13.43797 - which is what you got by trial and error.
 
  • #6
Thanks guys, you rock =]
 

FAQ: Algorithm for Generating Percentage Amounts

1. What is an algorithm for generating percentage amounts?

An algorithm for generating percentage amounts is a set of instructions or steps that a computer program follows to calculate a percentage based on a given input.

2. How does an algorithm for generating percentage amounts work?

An algorithm for generating percentage amounts typically involves multiplying a given number by a decimal representation of the percentage. For example, to calculate 20% of 100, the algorithm would multiply 100 by 0.20, resulting in an output of 20.

3. What is the purpose of using an algorithm for generating percentage amounts?

The purpose of using an algorithm for generating percentage amounts is to accurately and efficiently calculate percentages in various situations, such as in financial transactions or data analysis.

4. Are there different types of algorithms for generating percentage amounts?

Yes, there are various types of algorithms for generating percentage amounts, such as simple percentage, compound percentage, and weighted percentage. The type of algorithm used depends on the specific calculation needed.

5. Can an algorithm for generating percentage amounts be used for any type of percentage calculation?

While algorithms for generating percentage amounts can be used for many types of percentage calculations, they may not be suitable for all situations. It is important to understand the limitations and assumptions of a particular algorithm before using it for a specific calculation.

Similar threads

2
Replies
56
Views
8K
Replies
3
Views
830
Replies
3
Views
1K
Replies
11
Views
4K
2
Replies
61
Views
8K
Replies
25
Views
3K
2
Replies
48
Views
10K
Back
Top