mod calculation

C

Chad

I'm working on a school project. Part of the requirement is to read in
the following data file

37259 9819
46363 22666
46161 79934
5693 31416
91459 8272
72792 9493
83603 8372
77842 64629
84792 747
1299 178

And then calculate anyNewArrival and serviceTime based on the
following formulas...

//read data1 and data2 from the file
anyNewArrival = (((data1%100)+1) <=50);
serviceTime = (data2%5)+1);

where data1 and data2 are read from the file

I get the following by calculating anyNewArrival

37259 ----> 60 false
46363 -----> 64 false
46161 -----> 62 false
5693 ------>94 false
91459 ----> 60 false
72792 ----->93 false
83603 ----->04 true
77842 ----->43 true
84792 ----->93 false
1299 178 ----> 1000 false

That means the only two arrivals should be

83603 ----->04 true
77842 ----->43 true


However, according to the output he gave us in the class, the number
of arrivals are 4. Ideas?

Chad
 
R

Roedy Green

//read data1 and data2 from the file
anyNewArrival = (((data1%100)+1) <=50);
serviceTime = (data2%5)+1);

For the usual mod gotchas, see http://mindprod.com/jgloss/modulus.html

Most of the trouble comes when there are negative numbers involved.
You also might like to brush up on precedence.

http://mindprod.com/jgloss/precedence.html

The question I would ask myself is, "Which results do I agree with, my
prof's or my program's?". If "my program's", consider the
possibility you could have misunderstood the question, heard the prof
incorrectly or failed to take accurate notes during the class.
 
C

Chad

This is the sort of thing you really need to discuss with your
instructor or TA. You may be misunderstanding something in the
assignment, or have the wrong data file, or ...

I thought I had the wrong data file, so I downloaded again. However,
the numbers are the same.
There is something wrong with the last line of your output.
((data1%100)+1) is not 1000, regardless of the value of data1.

I was copying the results from the paper. that last line should be
100 false
 
C

Chad

For the usual mod gotchas, seehttp://mindprod.com/jgloss/modulus.html

Most of the trouble comes when there are negative numbers involved.
You also might like to brush up on precedence.

http://mindprod.com/jgloss/precedence.html

The question I would ask myself is, "Which results do I agree with, my
prof's or my program's?".  If "my program's",  consider the
possibility you could have misunderstood the question, heard the prof
incorrectly or failed to take accurate notes during the class.

Would it help if I took a picture of the handouts and then post a url
with these images to this group?
 
A

Andreas Leitgeb

If you got your assignment on paper, have another close look on
the paper, whether the "50" could have been really "60". If that's
the case, that might explain it.
 
R

Roedy Green

I thought I had the wrong data file, so I downloaded again. However,
the numbers are the same.

I repeat. You have to PARTITION the problem.

Is your program giving you wrong answers relative to what you expect
or are you in agreement the program and you both disagree with the
instructor? To answer that question you must manually solve the
problem using your understanding of what the question is.

If the latter, then nothing you do to the program will help (except
perhaps an evolutionary algorithm to see the profs results).

The problem is in your understanding of the problem. That has nothing
to do with the computer or the computer program. You will have to
solve it with social means, e.g. my asking fellow student, or the TA
how they interpreted the problem, or tell them what you thought and
wait for the irresistible urge to overtake them to correct you.

I know as I student I would have sooner cut off my arm than visit a
prof or TA to ask a favour, so try a fellow student.
 
G

Gene Wirchenko

On 11/14/2011 9:55 AM, Roedy Green wrote:
...

Why? Often, the fellow student does not know either.
Answering course-relevant questions from students is not a favor (or
favour) on the part of a professor or TA. It is part of their job.

One odd effect I noticed when I was a TA was that often the students who
were doing quite well on the course would ask questions, and the
students who were in trouble would not.

I have seen this, too. I graduated at the top of my class. I
frequently spoke with my instructors.
I don't know whether it was cause-and-effect, and if so in which
direction. However, there is at least a possibility that willingness to
ask the professor and/or TA causes good results.

It is also an opportunity to do something about it. Sometimes,
instructors make mistakes in assignments. Bringing something
suspicious to an instructor's attention may result in a correction to
the assignment.
As a result, I strongly advise asking them questions, even for things
that other people might be able to resolve.

In this particular case, if there is a mismatch between the results the
student thinks should be produced given the input, and the sample
output, I don't see how anyone other than the professor or TA can
resolve it reliably.

Quite.

Sincerely,

Gene Wirchenko
 
R

Roedy Green

Why? Often, the fellow student does not know either.

True, but if he has a mental block against visiting a TA as I did,
what else can he do? There is apparently something stopping him from
asking the TA.

Children who have been abused, as I was, will take extreme measures to
avoid asking permission or approaching authority figures, even when
they know that logically the odds of something horrible happening as a
result are low.

Both those activities are dangerous for the child, and the child
hardwires in avoidance.
 
L

Lew

True, but if he has a mental block against visiting a TA as I did,
what else can he do? There is apparently something stopping him from
asking the TA.

Children who have been abused, as I was, will take extreme measures to
avoid asking permission or approaching authority figures, even when
they know that logically the odds of something horrible happening as a
result are low.

The converse doesn't follow. Not everyone too foolish to ask the appropriate persons can claim it's because of a bad childhood. And not everyone whowas abused as a child hesitates to ask a T.A. for help with a school assignment.

Rationality is a hallmark of engineering behavior. Sometimes the rational act is to go to a person with the answers and ask your question. If you can't stand the heat, get out of the kitchen.
Both those activities are dangerous for the child, and the child
hardwires in avoidance.

If you want to succeed in life, you cannot live as a prisoner of your past.When a syndrome, obsession, addiction or phobia interferes with your ability to function, get professional help. The good news is that you can achieve satisfaction and happiness even with such handicaps.

I care, Roedy.
 
G

Gene Wirchenko

True, but if he has a mental block against visiting a TA as I did,
what else can he do? There is apparently something stopping him from
asking the TA.

Get over the block. And that is what he ought to do.

I have seen many a student try to bull his way through. Such
will bash his head into a wall. Ask him if he needs help, and chances
are, you will be told no, even though it is obvious he is foundering.

Scared of being thought to be ignorant? That seems to be a big
one. However, if you enrolled in a course, the general case if that
you effectively said, "I am ignorant, at least somewhat, in the
material of this course." We already know that you are ignorant. The
idea of taking the course was to relieve this ignorance, no? So quit
sabotaging yourself.
Children who have been abused, as I was, will take extreme measures to
avoid asking permission or approaching authority figures, even when
they know that logically the odds of something horrible happening as a
result are low.

An exceptional case being taken as a norm.
Both those activities are dangerous for the child, and the child
hardwires in avoidance.

Not hardwired. People can change.

Sincerely,

Gene Wirchenko
 
A

Andreas Leitgeb

Iirc, the OP (Chad) did explain it some time ago, in a previous thread,
that his "block" has mostly to do with his own work-hours completely
colliding with the teacher's (and probably the TA's, if there is one)
office-hours.
Also, that mailing the teacher about some problem typically got him
an "invitation to come by at office-hours" as reply.

I don't expect others to have read that other thread, or memorize
any particular tidbid of it. I happened to remember, and now I
posted the gist of it. I hope this will take the topic away from
speculations about what might keep Chad from asking his teacher.
 
R

Roedy Green

Get over the block. And that is what he ought to do.

Easier said that done. Have you ever been to workshops where people
work on such problems? Just because something is easy for you does not
mean it is easy for others.

If you are not an alcoholic you might say, "Well you idiot. Just stop
drinking. What could be easier than that?"
 
R

Roedy Green

Get over the block. And that is what he ought to do.

People usually don't recognise their phobias as something they should
get over. People afraid of spiders and snakes see their phobias as a
sensible reaction to a danger.

It was quite late in life when I realised I had to get rid of my
phobia of needles. It took about three days of intensive EMDR work.
It was so strange not being afraid of needles.

In my case, profs were simply scary people, unless approached in the
presence of a large number of people. I had an unconscious need of
witnesses to discourage the prof from attacking me. It didn't occur to
me at the time that my extreme reluctance to be in a room alone with a
prof was in any way unusual. I probably imagined other people felt
the same way, but were braver than I was. I did not think about it.
That was just the way the universe was.

In general, I feel uncomfortable around other people unless there is a
large audience. You might say I have reverse stage fright.

I think this comes from the fact my Mom behaved herself in the
presence of outside witnesses.

These are not rational thoughts. You can't argue yourself out of them,
any more than you can argue yourself out of feeling horny.
The most powerful tool I have discovered for neutralising them is
EMDR.
see http://mindprod.com/livinglove/methods/emdr.html
 
L

Lew

Roedy said:
Gene Wirchenko wrote, quoted or indirectly quoted someone who said :

People usually don't recognise their phobias as something they should
get over. People afraid of spiders and snakes see their phobias as a
sensible reaction to a danger.

It was quite late in life when I realised I had to get rid of my
phobia of needles. It took about three days of intensive EMDR work.
It was so strange not being afraid of needles.

In my case, profs were simply scary people, unless approached in the
presence of a large number of people. I had an unconscious need of
witnesses to discourage the prof from attacking me. It didn't occur to
me at the time that my extreme reluctance to be in a room alone with a
prof was in any way unusual. I probably imagined other people felt
the same way, but were braver than I was. I did not think about it.
That was just the way the universe was.

In general, I feel uncomfortable around other people unless there is a
large audience. You might say I have reverse stage fright.

I think this comes from the fact my Mom behaved herself in the
presence of outside witnesses.

These are not rational thoughts. You can't argue yourself out of them,
any more than you can argue yourself out of feeling horny.
The most powerful tool I have discovered for neutralising them is
EMDR.
see http://mindprod.com/livinglove/methods/emdr.html

That is fascinating information, Roedy, thank you.

That is perhaps the most interesting and potentially useful off-topic post I've seen here, so much so that it became honorarily on topic. I'll draw another thread to the topic in that to be a programmer, Java or otherwise, is a human activity. Pyschological impediments reduce one's effectiveness as a Java programmer, as in the OP's case. Programming isn't just about thecode, the language, the logic, the models and the idioms. It's also aboutthe practitioner and being mentally and physically capable of the act of programming.

So actually, your post is quite on topic. Your suggestion speaks to the maintenance and enhancement of the most universal, misunderstood and essential tool in the (Java) programmer's toolkit: their own mind.
 
A

Andreas Leitgeb

Lew said:
That is perhaps the most interesting and potentially useful off-topic post
I've seen here, so much so that it became honorarily on topic. I'll draw
another thread to the topic in that to be a programmer, Java or otherwise,
is a human activity. Pyschological impediments reduce one's effectiveness
as a Java programmer,

So far I agree.
as in the OP's case.

But what reliable source do you have for that claim?
 
R

Roedy Green

So actually, your post is quite on topic. Your suggestion speaks to the ma=
intenance and enhancement of the most universal, misunderstood and essentia=
l tool in the (Java) programmer's toolkit: their own mind.

I figured that the human mind is a biocomputer and as such it must
have algorithms, programs and such, the analogs of what we silicon
programmers use.

I am pretty sure we humans are going be embarrassed when we find out
nearly everything special about humans can be explained by a handful
of cheap bioprogramming tricks. It can't be that big a deal since all
the higher functions evolved so quickly. All the hard work was
getting to the insect level.

I remember when I first heard about artificial neural nets and their
way of composing and using algorithms without any understanding of how
they work. That sounds very human.

I hung out with Dr. John Lilly and Ken Keyes Jr. who approached the
notion is quite different ways. Terence McKenna is another. "Culture
is your OS". Tony Robbins teaches some practical techniques,
including "scrambling" which was key for me. Then there are the NLP
people and even the rebirthers.

The practical problem is how do you CHANGE your programming when you
realise it is defective, usually because some sort of trauma set it
off on a goofy track. This is the question I tackle at
http://mindprod.com/livinglove/methods.html
It is so much harder than changing silicon programming. We have
evolved a extreme attachment to any instructions we received as
children, no matter how bizarre or improbable. Darwin can tell you
why.

I used to lead workshops where I would help people change their
programming. It was quite amazing seeing a woman get over terror of
rape in just a few minutes, or long standing resentments evaporate.
One of things I am most happy with was an Israeli dentist with a rabid
hatred of Palestinians letting go of it in a couple of weeks during a
workshop I lead in England.

Most of the interesting work on understanding how the brain works has
been done on vision where we have a quite good understanding how
various creatures extract the useful feature information from the
flood of low level information.

My big aha moment was realising that my subjective waking experience
IS a dream, but one that takes in a lot of outside data to influence
it. This idea is so flaky and frightening to people that I rarely
mention my writings on the matter, but make people dig to find them,
and in the process get a feeling for who I am, before they find the
irrefutable evidence I am stark raving bonkers and hence dismiss what
I have to say without considering it.

Milton Erickson was hypnotist with amazing ability to change people's
programming. I laughed and laughed reading about some of the
unconventional things he did.

Then of course their is brainwashing/boot camp/cults/religious
conversion where the subject get melted down and reshaped with
programming selected by someone else.

I set about in 1976 to do a major overhaul of my own programming.
It has been quite successful though the progress was glacial. I am no
longer suicidal or frustrated. Many of the things other people do
that I used to find infuriating are now often entertaining. I have
very few needs. I don't feel deprived at all. That my ex suddenly
left and refused to talk to me or explain why he flipped from 100%
positive to 100% negative overnight used to drive me nuts. It
obsessed me for decades. Now I wonder what all the fuss was about. I
can even read a book while throwing up. And of course needles for the
various blood tests needed to manage HIV are not in the least
traumatic.

We have two kinds of programming. Emotion-backed programming is very
resistant to change. Whereas factual programming, e.g. your friend's
email address is trivial to change.

The point I was trying to make in the beginning is that emotion backed
programming can be clearly wrong, dysfunctional, nuts even, but that
is not sufficient for someone to discard it, no matter how much they
want to. They need techniques and a LOT of patience.
 
L

Lew

Andreas said:
So far I agree.


But what reliable source do you have for that claim?

None. None whatsoever. I should have said, "... as Roedy postulated for the OP's case."
 
A

Arne Vajhøj

Iirc, the OP (Chad) did explain it some time ago, in a previous thread,
that his "block" has mostly to do with his own work-hours completely
colliding with the teacher's (and probably the TA's, if there is one)
office-hours.
Also, that mailing the teacher about some problem typically got him
an "invitation to come by at office-hours" as reply.

I don't expect others to have read that other thread, or memorize
any particular tidbid of it. I happened to remember, and now I
posted the gist of it. I hope this will take the topic away from
speculations about what might keep Chad from asking his teacher.

But now you spoil the opportunity for people to make wild
speculations about OP's childhood.

Well done!!

:)

Arne
 
A

Arne Vajhøj

Easier said that done. Have you ever been to workshops where people
work on such problems? Just because something is easy for you does not
mean it is easy for others.

If you are not an alcoholic you might say, "Well you idiot. Just stop
drinking. What could be easier than that?"

Easy or difficult - the chance of changing if not trying to
change is small.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top