Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34313 > unrolled thread
| Started by | Duncan Idaho <duncan@dunenoemail.com> |
|---|---|
| First post | 2016-05-17 11:49 +0100 |
| Last post | 2016-05-17 17:49 -0400 |
| Articles | 20 on this page of 24 — 8 participants |
Back to article view | Back to comp.lang.java.programmer
Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 11:49 +0100
Re: Mathematics, Java, good enough Eric Douglas <e.d.programmer@gmail.com> - 2016-05-17 04:55 -0700
Re: Mathematics, Java, good enough Nigel Wade <nmw@ion.le.ac.uk> - 2016-05-17 12:56 +0100
Re: Mathematics, Java, good enough Nigel Wade <nmw@ion.le.ac.uk> - 2016-05-17 13:06 +0100
Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 13:29 +0100
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 09:54 -0400
Re: Mathematics, Java, good enough FredK <fred.l.kleinschmidt@gmail.com> - 2016-05-17 07:17 -0700
Re: Mathematics, Java, good enough FredK <fred.l.kleinschmidt@gmail.com> - 2016-05-17 07:29 -0700
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 10:58 -0400
Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 18:10 +0100
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 14:02 -0400
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 14:10 -0400
Re: Mathematics, Java, good enough Eric Douglas <e.d.programmer@gmail.com> - 2016-05-17 11:36 -0700
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 16:12 -0400
Re: Mathematics, Java, good enough Eric Douglas <e.d.programmer@gmail.com> - 2016-05-17 13:56 -0700
Re: Mathematics, Java, good enough Gene Wirchenko <genew@telus.net> - 2016-05-17 14:13 -0700
Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-18 05:06 +0100
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 08:25 -0400
Re: Mathematics, Java, good enough Martin Gregorie <martin@address-in-sig.invalid> - 2016-05-17 12:24 +0000
Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 18:15 +0100
Re: Mathematics, Java, good enough Jerry Stuckle <jstucklex@attglobal.net> - 2016-05-17 13:33 -0400
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 14:09 -0400
Re: Mathematics, Java, good enough Gene Wirchenko <genew@telus.net> - 2016-05-17 14:17 -0700
Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 17:49 -0400
Page 1 of 2 [1] 2 Next page →
| From | Duncan Idaho <duncan@dunenoemail.com> |
|---|---|
| Date | 2016-05-17 11:49 +0100 |
| Subject | Mathematics, Java, good enough |
| Message-ID | <nhesp7$hn7$1@dont-email.me> |
Hello again
I have a question that involves mathematics. I agree that it's off topic but as I am writing in Java
I thought I'd give it a go (tenuous I know but it's the best I've got).
I'm dredging up set theory from the furthest reaches of my memory. I'll probably get it wrong.
Homework? If only, that would mean I could have the last 50 years again ... perhaps not. %-)
Anyway
I have a set of characters S of cardinality C
example
if S = {a..z, 0..9, A..Z} then C = er, um ..,62.
For any given result string X, X need not be a set.
eg if L = 8 then
"abcdefgh", "AAAAAAAA", "AABBCCDD" are all valid values for X
how many strings of length L are possible from S
I don't even know what to call the question and I probably won't understand the answer but it will be fun trying.
TIA
Idaho
--
Duncan Idaho
!(ghola mentat)
[toc] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2016-05-17 04:55 -0700 |
| Message-ID | <a6a4c649-e30f-4a18-b8a3-6d1a722ab572@googlegroups.com> |
| In reply to | #34313 |
On Tuesday, May 17, 2016 at 6:49:48 AM UTC-4, Duncan Idaho wrote:
> I have a set of characters S of cardinality C
> example
> if S = {a..z, 0..9, A..Z} then C = er, um ..,62.
>
> For any given result string X, X need not be a set.
>
> eg if L = 8 then
> "abcdefgh", "AAAAAAAA", "AABBCCDD" are all valid values for X
>
> how many strings of length L are possible from S
If a..z + 0..9 + A..Z are valid characters for each position of a string, that's 62 possible characters. The number of possible combinations is 62 to the L (length) power.
The simplest example is binary. If each character may be 1 or 0, string of 3 characters is 2 * 2 * 2 = 8
000
001
010
100
011
110
111
101
[toc] | [prev] | [next] | [standalone]
| From | Nigel Wade <nmw@ion.le.ac.uk> |
|---|---|
| Date | 2016-05-17 12:56 +0100 |
| Message-ID | <dq0f7gFnat7U1@mid.individual.net> |
| In reply to | #34313 |
On 17/05/16 11:49, Duncan Idaho wrote:
> Hello again
>
> I have a question that involves mathematics. I agree that it's off topic but as I am writing in Java
> I thought I'd give it a go (tenuous I know but it's the best I've got).
>
> I'm dredging up set theory from the furthest reaches of my memory. I'll probably get it wrong.
> Homework? If only, that would mean I could have the last 50 years again ... perhaps not. %-)
>
> Anyway
>
> I have a set of characters S of cardinality C
> example
> if S = {a..z, 0..9, A..Z} then C = er, um ..,62.
>
> For any given result string X, X need not be a set.
>
> eg if L = 8 then
> "abcdefgh", "AAAAAAAA", "AABBCCDD" are all valid values for X
>
> how many strings of length L are possible from S
>
> I don't even know what to call the question and I probably won't understand the answer but it will be fun trying.
>
The answer is pretty simple. 62^8.
The reasoning is also pretty simple.
The first character has 62 possibilities.
The second character also has 62 possibilities, so the first 2 characters have 62*62 possibilities (62^2)
The third character also has 62 possibilities, so the first 3 characters have 62*62*62 possibilities (62^3)
In general, for L from S, the number of possibilities is S^L.
If you are not convinced, then just remove the letters and work with the numbers.
The first digit can be 0-9. The second digit can be 0-9, so the allowed values are 00-99. And so on. This ought to be
quite familiar. For 8 digits the range of possibilities would be 00000000-99999999.
I'm not sure of the specific name is, most likely combination of probabilities.
[toc] | [prev] | [next] | [standalone]
| From | Nigel Wade <nmw@ion.le.ac.uk> |
|---|---|
| Date | 2016-05-17 13:06 +0100 |
| Message-ID | <dq0fprFne49U1@mid.individual.net> |
| In reply to | #34315 |
On 17/05/16 12:56, Nigel Wade wrote: > I'm not sure of the specific name is, most likely combination of probabilities. > This is what wikipedia thinks it's called: https://en.wikipedia.org/wiki/Permutation#Permutations_with_repetition
[toc] | [prev] | [next] | [standalone]
| From | Duncan Idaho <duncan@dunenoemail.com> |
|---|---|
| Date | 2016-05-17 13:29 +0100 |
| Message-ID | <nhf2l1$6dn$1@dont-email.me> |
| In reply to | #34315 |
On 17/05/16 12:56, Nigel Wade wrote:
> On 17/05/16 11:49, Duncan Idaho wrote:
>> Hello again
>>
>> I have a question that involves mathematics. I agree that it's off topic but as I am writing in Java
>> I thought I'd give it a go (tenuous I know but it's the best I've got).
>>
>> I'm dredging up set theory from the furthest reaches of my memory. I'll probably get it wrong.
>> Homework? If only, that would mean I could have the last 50 years again ... perhaps not. %-)
>>
>> Anyway
>>
>> I have a set of characters S of cardinality C
>> example
>> if S = {a..z, 0..9, A..Z} then C = er, um ..,62.
>>
>> For any given result string X, X need not be a set.
>>
>> eg if L = 8 then
>> "abcdefgh", "AAAAAAAA", "AABBCCDD" are all valid values for X
>>
>> how many strings of length L are possible from S
>>
>> I don't even know what to call the question and I probably won't understand the answer but it will be fun trying.
>>
>
> The answer is pretty simple. 62^8.
> The reasoning is also pretty simple.
Well strangely enough I did try that but according to my Ubuntu desktop calculator
62^8 is 2.183401056×10^14
I think that means move the decimal point 14 places to the right which gives
218340105600000 or 218,340,105,600,000 which I think is (deep breath)
two hundred and eighteen trillion three hundred and forty billion one hundred and five million six hundred thousand
8 character strings and I thought it must be wrong, that's an *huge* number
Is this correct
Thanks to you both for taking the time to reply
Idaho
>
> The first character has 62 possibilities.
> The second character also has 62 possibilities, so the first 2 characters have 62*62 possibilities (62^2)
> The third character also has 62 possibilities, so the first 3 characters have 62*62*62 possibilities (62^3)
> In general, for L from S, the number of possibilities is S^L.
>
> If you are not convinced, then just remove the letters and work with the numbers.
> The first digit can be 0-9. The second digit can be 0-9, so the allowed values are 00-99. And so on. This ought to be quite
> familiar. For 8 digits the range of possibilities would be 00000000-99999999.
>
>
> I'm not sure of the specific name is, most likely combination of probabilities.
>
>
>
--
Duncan Idaho
!(ghola mentat)
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-05-17 09:54 -0400 |
| Message-ID | <nhf7kk$o1p$1@dont-email.me> |
| In reply to | #34319 |
On 5/17/2016 8:29 AM, Duncan Idaho wrote:
> On 17/05/16 12:56, Nigel Wade wrote:
>> [...]
>> The answer is pretty simple. 62^8.
>> The reasoning is also pretty simple.
>
> Well strangely enough I did try that but according to my Ubuntu desktop
> calculator
> 62^8 is 2.183401056×10^14
Sounds about right. 62 is 2^6 (you're using the back of an
envelope, right?), so 62^8 is (2^6)^8 = 2^48. Since 2^10 = 10^3
(envelope...), 2^48 = (2^50)/4 = 10^15/4 = 2.5*10^14 = your answer.
> 8 character strings and I thought it must be wrong, that's an *huge* number
Next time you hear somebody say something grows "exponentially,"
maybe you'll understand what's been said. (Maybe you'll understand
it better than the speaker, who's next sentence will probably contain
the words "paradigm" and "quantum," neither of which he understands
any better than "exponentially" ...)
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | FredK <fred.l.kleinschmidt@gmail.com> |
|---|---|
| Date | 2016-05-17 07:17 -0700 |
| Message-ID | <768508de-3c08-4d46-8c68-8a5f8b7db533@googlegroups.com> |
| In reply to | #34320 |
The question arises whether you really want to know how many distinguishable strinmgs there are, which is much smaller if the original set contains duplicate entries.
[toc] | [prev] | [next] | [standalone]
| From | FredK <fred.l.kleinschmidt@gmail.com> |
|---|---|
| Date | 2016-05-17 07:29 -0700 |
| Message-ID | <ff57f7e8-2d3a-4fb0-a9fe-763965a76af3@googlegroups.com> |
| In reply to | #34321 |
On Tuesday, May 17, 2016 at 7:17:23 AM UTC-7, FredK wrote: > The question arises whether you really want to know how many distinguishable strinmgs there are, which is much smaller if the original set contains duplicate entries. For example, if the set it "AAB" there are only 3 distinguishable strings of length 2: AA, AB, and BA
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-05-17 10:58 -0400 |
| Message-ID | <nhfbce$6ii$1@dont-email.me> |
| In reply to | #34322 |
On 5/17/2016 10:29 AM, FredK wrote:
> On Tuesday, May 17, 2016 at 7:17:23 AM UTC-7, FredK wrote:
>> The question arises whether you really want to know how many distinguishable strinmgs there are, which is much smaller if the original set contains duplicate entries.
> For example, if the set it "AAB" there are only 3 distinguishable strings of length 2: AA, AB, and BA
What happened to "BB"? I think you're writing about a
situation that doesn't match the O.P.'s question.
The O.P. wrote that he had a "set of characters," and went
on to mention its "cardinality" -- from this, I understood him
to mean that he actually had a "set." {A A B} is not a set.
(It's a multiset, yes, but not a set.)
import java.util.HashSet;
public class TryMe {
public static void main(String[] unused) {
HashSet<Character> set = new HashSet<>();
set.add('A');
set.add('A');
set.add('B');
System.out.println(set.size());
}
}
If the output is "3", your Java is broken. ;)
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | Duncan Idaho <duncan@dunenoemail.com> |
|---|---|
| Date | 2016-05-17 18:10 +0100 |
| Message-ID | <nhfj31$509$1@dont-email.me> |
| In reply to | #34324 |
On 17/05/16 15:58, Eric Sosman wrote:
> On 5/17/2016 10:29 AM, FredK wrote:
>> On Tuesday, May 17, 2016 at 7:17:23 AM UTC-7, FredK wrote:
>>> The question arises whether you really want to know how many distinguishable strinmgs there are, which is much smaller if the
>>> original set contains duplicate entries.
>> For example, if the set it "AAB" there are only 3 distinguishable strings of length 2: AA, AB, and BA
>
> What happened to "BB"? I think you're writing about a
> situation that doesn't match the O.P.'s question.
>
> The O.P. wrote that he had a "set of characters," and went
> on to mention its "cardinality" -- from this, I understood him
> to mean that he actually had a "set."
This is correct. I was using the word 'set' to mean (mathematically)
a collection of well defined and distinct objects (NOT java.util.Collection interface of course :-)
Cardinality as in 'the cardinality of a finite set'
as opposed to the cardinality of an infinite set which I believe to be a mathematical principle
that makes as much sense to me as the idea that time existed before there was anyone to measure it.
I mean the cardinality of an infinite set is infinite isn't it ... jeez, math has always made my head spin
Glad we got it sorted out though. c.l.j.p really is a 'resource' isn't it.
{A A B} is not a set.
> (It's a multiset, yes, but not a set.)
>
> import java.util.HashSet;
> public class TryMe {
> public static void main(String[] unused) {
> HashSet<Character> set = new HashSet<>();
> set.add('A');
> set.add('A');
> set.add('B');
> System.out.println(set.size());
> }
> }
>
> If the output is "3", your Java is broken. ;)
>
--
Duncan Idaho
!(ghola mentat)
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-05-17 14:02 -0400 |
| Message-ID | <nhfm4j$i8t$1@dont-email.me> |
| In reply to | #34325 |
On 5/17/2016 1:10 PM, Duncan Idaho wrote:
> ... jeez,
> math has always made my head spin
Okay -- but if you're going to be any good at programming you'd
better get at least *some* grounding. For example: Can you see the
connection between your original question ("How many 8-char strings
from an alphabet of 26 characters?") and the question of how many
8-digit base-62 numbers there are? If not, it may be time to re-
examine your career choices ... :)
Also, I'd encourage you to develop some facility at mental
arithmetic. Not multiplying eight-digit numbers or anything like
that, but more along the lines I illustrated a couple posts ago,
using a bunch of sloppy but handy approximations to sanity-check
a result you got from your calculator. It's not that the sloppy
result is "reliable" -- mine was only correct to one significant
digit! -- but if the calculator and the approximation are vastly
different, like 2E14 and 6E8, that should alert you to go back and
double-check before trusting either answer.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-05-17 14:10 -0400 |
| Message-ID | <nhfmjt$k0m$1@dont-email.me> |
| In reply to | #34328 |
On 5/17/2016 2:02 PM, Eric Sosman wrote:
> On 5/17/2016 1:10 PM, Duncan Idaho wrote:
>> ... jeez,
>> math has always made my head spin
>
> Okay -- but if you're going to be any good at programming you'd
> better get at least *some* grounding. For example: Can you see the
> connection between your original question ("How many 8-char strings
> from an alphabet of 26 characters?") and the question of how many
s/26/62/
> 8-digit base-62 numbers there are? If not, it may be time to re-
> examine your career choices ... :)
>sigh<
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2016-05-17 11:36 -0700 |
| Message-ID | <7eb8f161-ca45-489f-bfdb-4f96b534790d@googlegroups.com> |
| In reply to | #34328 |
On Tuesday, May 17, 2016 at 2:02:30 PM UTC-4, Eric Sosman wrote:
> Okay -- but if you're going to be any good at programming you'd
> better get at least *some* grounding. For example: Can you see the
> connection between your original question ("How many 8-char strings
> from an alphabet of 26 characters?") and the question of how many
> 8-digit base-62 numbers there are? If not, it may be time to re-
> examine your career choices ... :)
What about fuzzy math?
ie What should be the minimum length of a string to use for an ID # for 30,000,000 government employees (military vets) using the standard upper and lower case alphabet and digits 0-9 and 8 special characters !@#$%^&* in order to create a unique ID for each current employee, allow for as many future employees, and not make it easy for someone to guess a valid employee ID?
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-05-17 16:12 -0400 |
| Message-ID | <nhftoj$ik2$1@dont-email.me> |
| In reply to | #34332 |
On 5/17/2016 2:36 PM, Eric Douglas wrote:
> On Tuesday, May 17, 2016 at 2:02:30 PM UTC-4, Eric Sosman wrote:
>> Okay -- but if you're going to be any good at programming you'd
>> better get at least *some* grounding. For example: Can you see the
>> connection between your original question ("How many 8-char strings
>> from an alphabet of 26 characters?") and the question of how many
>> 8-digit base-62 numbers there are? If not, it may be time to re-
>> examine your career choices ... :)
>
> What about fuzzy math?
> ie What should be the minimum length of a string to use for an ID # for 30,000,000 government employees (military vets) using the standard upper and lower case alphabet and digits 0-9 and 8 special characters !@#$%^&* in order to create a unique ID for each current employee, allow for as many future employees, and not make it easy for someone to guess a valid employee ID?
30,000,000 ~= 2^5 * 10^6 ~= 2^5 * 2^20 = 2^25 individuals, so we
need about 25 bits of "payload" to distinguish them. To obfuscate,
we can arrange that there will be N non-ID's for each real ID, and
then choose an N that fits our notion of "not make it easy." Let's
suppose we choose "not easy" to be N = 1,000,000, that is, only one
in a million potential ID strings is an actual ID. So N ~= 2^20 and
we need 20 extra bits in addition to the payload, 45 bits in all.
The alphabet you suggest has 70 ~= 2^6 characters, so each
character is worth a little over 6 bits. 45 divided by "a little
over 6" is 7, so strings of 7 characters should about do it.
Check: 3E7 individuals times N=1E6 for "not too easy" = 3E13
potential ID strings. log(3E13)/log(70) ~= 7.3 (calculator), in
good agreement with the back-of-the-envelope figure. For safety's
sake, I'd round up to 8 instead of down to 7.
See how it's done, "Duncan Idaho?" This sort of calculation is
a programmer's bread and butter; better develop a taste for it.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2016-05-17 13:56 -0700 |
| Message-ID | <392b1929-7e84-4042-80a1-f3ea4ed37591@googlegroups.com> |
| In reply to | #34334 |
On Tuesday, May 17, 2016 at 4:12:37 PM UTC-4, Eric Sosman wrote: > See how it's done, "Duncan Idaho?" This sort of calculation is > a programmer's bread and butter; better develop a taste for it. Ah the joys of computer programming. I intentionally work for a small business with small demands. I previously worked for a very large company and the code can be mind boggling, large volumes of data stored in poorly designed table structures... These days the US government loves to make big demands of computer programmers. Previously there was the infamous thing called Obamacare, a health care system that contracted out the development of a web site with poor coordination and a short time frame to handle massive amounts of data. The latest debacle is called the VA. (http://www.npr.org/2016/05/17/478215589/how-congress-and-the-va-left-many-veterans-without-a-choice) Given $10,000,000,000 and 90 days they had to set up a system which no doubt involved a lot of computer coding. One of the requirements was issuing ID cards. I don't know where they got the data for the new system, if they set up a whole new database with any sort of connection to an existing database or with a datafile to import, but I'm guessing they had to create a new ID for each user in the new system. This report states there were 28,287 vets, but of course programmers must set up a system to allow for many more. How many are active duty who may become vets? How long might the system be in place? Do we want to reuse ID numbers? That's just the start of the headaches. Once they created a system and populated it with data and printed ID cards, they had to set up an application for call center employees to access the data, add in some data for a network of doctors, set up an appointment scheduler and claims process... I'm not at all surprised the contractors felt 90 days was not enough time. Yes, we have to be able to do rough calculations. If an ID is a key to a data table and it's not big enough it could be a nightmare as the system hits the limit, and that's just one of many possible nightmares in programming, particularly on large scale projects.
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2016-05-17 14:13 -0700 |
| Message-ID | <uv1njbh18bkk22gkrhfa8fbe5t541k49j3@4ax.com> |
| In reply to | #34328 |
On Tue, 17 May 2016 14:02:16 -0400, Eric Sosman
<esosman@comcast-dot-net.invalid> wrote:
>On 5/17/2016 1:10 PM, Duncan Idaho wrote:
>> ... jeez,
>> math has always made my head spin
>
> Okay -- but if you're going to be any good at programming you'd
>better get at least *some* grounding. For example: Can you see the
>connection between your original question ("How many 8-char strings
>from an alphabet of 26 characters?") and the question of how many
>8-digit base-62 numbers there are? If not, it may be time to re-
>examine your career choices ... :)
>
> Also, I'd encourage you to develop some facility at mental
>arithmetic. Not multiplying eight-digit numbers or anything like
>that, but more along the lines I illustrated a couple posts ago,
>using a bunch of sloppy but handy approximations to sanity-check
>a result you got from your calculator. It's not that the sloppy
>result is "reliable" -- mine was only correct to one significant
>digit! -- but if the calculator and the approximation are vastly
>different, like 2E14 and 6E8, that should alert you to go back and
>double-check before trusting either answer.
I second this.
Going further, I use this model when teaching math. There are
three things to concern yourself with:
1) translating from the problem domain to mathematical language,
2) doing the mathematical calculations, and
3) translating the mathematical results back to the problem domain.
The most important is #1, next is #3, and last is #2.
We have calculators that can do a lot of the math. Getting into
and out of mathematical forms is much tougher.
Too many people concentrate on #2. That is one reason why so
many have trouble with word problems.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Duncan Idaho <duncan@dunenoemail.com> |
|---|---|
| Date | 2016-05-18 05:06 +0100 |
| Message-ID | <nhgphu$5hk$1@dont-email.me> |
| In reply to | #34328 |
On 17/05/16 19:02, Eric Sosman wrote:
> On 5/17/2016 1:10 PM, Duncan Idaho wrote:
>> ... jeez,
>> math has always made my head spin
>
> Okay -- but if you're going to be any good at programming you'd
> better get at least *some* grounding. For example: Can you see the
> connection between your original question ("How many 8-char strings
> from an alphabet of 26 characters?") and the question of how many
> 8-digit base-62 numbers there are? If not, it may be time to re-
> examine your career choices ... :)
Well that's very interesting.
> Also, I'd encourage you to develop some facility at mental
> arithmetic.
I came to computing late in life. I was 30 before I got into them (around 1988)
prior to that I grew hardy nursery stock for a living (hard work) and ran a plant stall at the local market
In the spring, at the market I would serve 3 customers at a time, keeping a running total for each in my head.
I rarely made a mistake. I can do mental arithmetic. The problem comes when I see numbers written down
I can't even dial a telephone number if it's written down on paper. If it's in my head no problem.
As for making career out of computers, well I retired at 48 entirely because I just 'got' the whole software engineering thing.
No idea where it comes from but give me a paper based business and I'll transpose it to silicon, in Java, and make it work.
Solutions just pop into my head. Now I code for fun, run a small on line business and help other 'matures' to learn
'programming' some of them 'just do it' others I can sit there with for hours and get nowhere.
My problem (apparently) is known as partial number blindness. If I see numbers written down my brain just shuts down.
It's a recognized learning disability. Strangely enough I used to do very well (90%+) in the formal notations exams.
I actually find mathematics fascinating, I wish I could 'do it'
Ah well
Thanks for taking the time to reply
Idaho
> Not multiplying eight-digit numbers or anything like
> that, but more along the lines I illustrated a couple posts ago,
> using a bunch of sloppy but handy approximations to sanity-check
> a result you got from your calculator. It's not that the sloppy
> result is "reliable" -- mine was only correct to one significant
> digit! -- but if the calculator and the approximation are vastly
> different, like 2E14 and 6E8, that should alert you to go back and
> double-check before trusting either answer.
>
--
Duncan Idaho
!(ghola mentat)
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-05-17 08:25 -0400 |
| Message-ID | <nhf2cv$5lk$1@dont-email.me> |
| In reply to | #34313 |
On 5/17/2016 6:49 AM, Duncan Idaho wrote:
> Hello again
>
> I have a question that involves mathematics. I agree that it's off topic
> but as I am writing in Java
> I thought I'd give it a go (tenuous I know but it's the best I've got).
>
> I'm dredging up set theory from the furthest reaches of my memory. I'll
> probably get it wrong.
> Homework? If only, that would mean I could have the last 50 years again
> ... perhaps not. %-)
>
> Anyway
>
> I have a set of characters S of cardinality C
> example
> if S = {a..z, 0..9, A..Z} then C = er, um ..,62.
>
> For any given result string X, X need not be a set.
>
> eg if L = 8 then
> "abcdefgh", "AAAAAAAA", "AABBCCDD" are all valid values for X
>
> how many strings of length L are possible from S
There are Math.pow(C, L) strings of exactly L characters,
or (Math.pow(C, L+1) - 1) strings of "zero through L" characters.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2016-05-17 12:24 +0000 |
| Message-ID | <nhf2ho$mg7$1@dont-email.me> |
| In reply to | #34313 |
On Tue, 17 May 2016 11:49:27 +0100, Duncan Idaho wrote:
> Hello again
>
> I have a question that involves mathematics. I agree that it's off topic
> but as I am writing in Java I thought I'd give it a go (tenuous I know
> but it's the best I've got).
>
> I'm dredging up set theory from the furthest reaches of my memory. I'll
> probably get it wrong.
> Homework? If only, that would mean I could have the last 50 years again
> ... perhaps not. %-)
>
> Anyway
>
> I have a set of characters S of cardinality C example if S = {a..z,
> 0..9, A..Z} then C = er, um ..,62.
>
> For any given result string X, X need not be a set.
>
> eg if L = 8 then "abcdefgh", "AAAAAAAA", "AABBCCDD" are all valid values
> for X
>
> how many strings of length L are possible from S
>
> I don't even know what to call the question and I probably won't
> understand the answer but it will be fun trying.
>
Lets see - there are C ways to choose the first character and since, from
your examples, the set members available for use as the second and
subsequent positions aren't restricted by earlier choices, there are also
C ways to choose the set member for all L positions in the result string.
This means there are C^N possible strings (C^N is C raised to the Nth
power).
Restating and calculating this in Java gives:
$ cat SetTheory.java
public class SetTheory
{
public static void main(String args[])
{
double possibleStrings = Math.pow(62, 8);
System.out.println("62^8 = " + possibleStrings);
}
}
$ javac SetTheory.java
$ java SetTheory
62^8 = 2.18340105584896E14
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
[toc] | [prev] | [next] | [standalone]
| From | Duncan Idaho <duncan@dunenoemail.com> |
|---|---|
| Date | 2016-05-17 18:15 +0100 |
| Message-ID | <nhfjd2$6da$1@dont-email.me> |
| In reply to | #34313 |
On 17/05/16 15:43, Stefan Ram wrote: > Duncan Idaho <duncan@dunenoemail.com> writes: >> how many strings of length L are possible from > ... >> a set of characters S of cardinality C > > If an alphabet has C members, there are C^L words of length > L over it, because for every word position, there are C choices, > and the choices of positions multiply as one can easily see. > > For example, an octet of bit memory cells has java.lang.Math.pow > ( 2, 8 ) possible states. A UHD screen with 24 bits of color can > show java.math.BigInteger.valueOf( 2<<23 ).pow( 7680 * 4320 ) > different pictures. hmm That last one was too easy for you guys obviously :-) So what if I said how many *sets* of cardinality C are there in a set S of cardinality SC Example so where C = 8 then "ABCDEFGH" is good but "AABCDEFG" isn't Idaho -- Duncan Idaho !(ghola mentat)
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web