as an example怎么用 of what is going on

What is the XY problem? - Meta Stack Exchange
to customize your list.
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.
Here's how it works:
Any Stack Exchange user can ask a question
The community provides support, votes on ideas, and reports bugs
Your voice helps shape the way Stack Exchange operates
What is the XY problem?
When asking questions, how do I recognize when I'm falling into it?
How do I avoid it?
What is it?
is asking about your attempted solution rather than your actual problem.
That is, you are trying to solve problem X, and you think solution Y would work, but instead of asking about X when you run into trouble, you ask about Y.
The Problem
This can lead to frustration by people who are trying to help you solve the problem because by the time you ask about it, the solution that you need help with might not have any obvious connections to the problem that you are trying to solve.
How to Avoid
To avoid falling into this trap, always include information about a broader picture along with any attempted solution.
If someone asks for more information, or especially a more specific question, do provide details.
If there are other solutions which you believe will be suggested and which you've already ruled out, then don't try to avoid going over them again – instead state why you've ruled them out, as this gives more information about your requirements and helps others provide better answers.
An Example
A recent IRC conversation for illustration:
Q: Is there a function to return a string between two delimiters?
B: i don't understand what you mean, but i doubt there's already a function
C: split and slice
D: partition too
Q: I tried partition
Q: I was trying to use built-ins to get the number between something like this in a string "attribute1: 50.223, attribute2: 442.1"
D: why not just parse the string?
Q: I thought there may have been some built in parsing stuff
D: pairs = [x.strip() for x in s.split(",")]; attribs = {k: v for x in pairs for k, v in x.split(": ")}
D: there's a few libraries, but simplistic formats are easy enough -- if you don't care about error handling
D: changing the source to use a well known format, e.g. json or yaml, is preferred when possible
Q: This code actually comes from HTML
Q: but I don't know how to parse Javascript with HTMLParser or whatever it's called
D: is it merely embedded in html, or some mangled version of html?
Q: It's embedded in the HTML
D: if it's javascript (and that is, except for missing outer braces), json can probably parse it
D: I didn't say it explicitly: json only parses data structures, not js code
Q: That's all I need parsed is a data structure
The problem is really about how to parse JavaScript data structures, not find "a string between two delimiters", yet it takes quite a bit of time and intuition to get to the real issue.
This is easier to do in a fully interactive chat (regardless of what mode), but on a SE site, where you polish a post a bit, post it, and then have 5-30 mins, or longer, before feedback, it really helps to head in the right direction from the start.
The X-Y Problem, as it is sometimes called, is a mental block which leads to
enormous amounts of wasted time and energy, both on the part of people asking
for help, and on the part of those providing help. It often goes something like
User wants to do X.
User doesn't know how to do X, but thinks they can fumble their way to a
solution if they can just manage to do Y.
User doesn't know how to do Y either.
User asks for help with Y.
Others try to help user with Y, but are confused because Y seems like a
strange problem to want to solve.
After much interaction and wasted time, it finally becomes clear that the user
really wants help with X, and that Y wasn't even a suitable solution for X.
The problem occurs when people get their train of thought stuck on one approach
and become unable to take a step back. Remaining open to having a new look at
the bigger picture, these people might find their way back to X and continue
searching for alternative solutions.
I'm adding an extra answer as a complement to the excellent answers already present.
An XY problem seems to be a subset of the , where a problem-solver gets stuck on a particular solution and is unable to backtrack mentally to see potentially superior solutions. This psychological phenomenon affects everyone, novices and experts alike.
would be a person winning with a 5-move smothered mate in one game. The next game, the same player fails to see a faster 3-move mate because they are stuck on the idea of a 5-move mate.
Specific to Q&A, the perniciousness of an XY problem comes from the fact that it is frustrating for everyone involved:
The person asking the question asks the wrong question (which is related to their attempted solution rather than the original problem), and then finds it difficult to clarify the question because they are stuck on their own solution. The proposed answers are unsatisfactory because they don't address how to implement the author's solution.
People answering the question find it frustrating because the proposed solution doesn't make sense to them since they are approaching the problem from a fresh angle and are (presumably) not being affected by the Einstellung effect, and they find it difficult to get the original poster to clarify their question.
problem is a good illustration. It illustrates a simple and universal problem/question/solution process, where "some illusion" causes complications.
There are a self-evident problem & the 1×1 hole in that arises on the second figure &, but the solution is evident only after we know (like an Egg of Columbus)... All people, experts and non-experts, agree that there is a problem.
normal user: thinks that "there are two equivalent figures, the 'total triangles' in a perfect 13×5 grid...", following with the question:
problem Y: "Why the second equivalent triangle have a hole in it?".
expert user: think something like "oops, they are similar, but not 'perfectly equivalent' figures", following with the question:
problem X: "How to show that they are not perfect equivalents?".
The clever geometry-expert thinks in terms of "similar geometries that aren't perfect equivalents".
The normal user thinks, mistakenly, in terms of exact . So, the
use of wrong hypothesis, produce ill Y questions.
The "XY problem" as a specialization of the "wrong hypothesis behaviour"
You want to solve the real question-X, and you think in terms of an Y-context, and try to use question-Y. Instead of asking about context X, you ask about context Y.
(as , but using other words)
So, "XY Problem" is only another (more specialized) term to say "Use of ".
Avoiding the XY problem
I argue that you can't avoid it.
Not without simply throwing your program requirements at SO and asking them to do your design for you (not recommended).
I argue this because the design process for all software is based on a starting set of requirements "A".
From there you say "I can achieve A if I do B and C".
From there you say "I can achieve B if I do D and E and I can achieve C if I do F and G". And that continues to the point we say that "I can achieve X if I do Y".
We usually do this so fast we don't even think about the process.
So the major problem with the XY problem is that Y is not possible, but you don't know how much of your design to unwind to get back to the X which is possible.
You usually don't even know that Y is impossible without actually asking. You don't know what you don't know. Therefore it is unavoidable
Asking Questions where you risk falling into XY
The best thing you can do about the XY problem is to guard against it when asking questions.
Still ask the same question but give as much pertinent information as possible:
State your problem
State what you are trying to achieve
State how it fits into your wider design
This will help people identify that its XY and help you much more quickly.
IMPORTANT: Giving Answers to XY problems
In my opinion the biggest problem with XY questions is the (frequently) unhelpful answers they provoke.
We will never stop people asking these questions so the best thing is to understand how we can answer them quickly and effectively.
Ironically a lot of these bad answers and responses are given by those wanting to be the most helpful and can be given by some of the most reputable people on the forum / SO.
I've discovered a method of answering these questions which appears to help get round the psychology associated with XY problems and lead the OP of a question to a working solution.
The method takes a little longer to answer in the first instance but closes the Q/A loop much more quickly.
I suggest that you answer the question in three parts and give them in the following order.
Answer the OP's question.
Even though the OP probably needs something else, never neglect to answer the question they have actually asked first and not the question you think they want answered.
In some cases that answer may be "Y is not possible".
Too often I see responses (comments) asking "why do you need that?".
This gives the OP nothing.
If you say "That's going to be really hard. Explain why you need it we may be able to help" then in a lot of cases an OP will simply take the "Y is really hard" and go back to the drawing board... That's fine because you've answered their question and they may well come back with question X themselves.
Discuss the OP's attempted solution.
This bit's tricky and takes some thought.
But I can't stress how important it is.
If the OP has asked for Y and you think they want X then after answering their question (1) carry on to talking about Y (NOT X).
What is Y supposed to be used for?
How is it not applicable to X?
The crucial thing is to carry on talking about the question but move from answering it to providing helpful information.
Because after all that's what you think the OP needs.
Helpful information and not the answer to their question.
Solve X This is what you've been itching to do and is the whole point of your response after all.
You've met the OP on their terms and answered their question.
You've helped them to understand the failings of their question and why solving Y is not the thing to do... so now you're completely justified in explaining a solution to X.
Most people are here to learn so parts 1 and 2 of this answer are as important as part 3.
But too often part 3 is given on it's own and it is extremely frustrating and patronising to the OP not to mention a lot of OPs will not accept the answer.
Giving this answer also avoids embarrassment when you think the OP has an XY problem when in fact they don't.
All you've done is give a little extra information.
Simply giving part 3 risks appearing to have not read the question.
Incidentally.
Read the question again and read this answer... notice the three parts?
(separated from my other answer because this one has more opinion than explanation)
If you agree that the "XY Problem" is only another (more specialized) term for "Use of wrong working hypothesis", as , and similar to the "Einstellung effect" &
We can think in terms of some main situations:
Rush situation: the wrong hypothesis is only a language or over-simplification side-effect, that can be corrected by the user with a little more attention, and investing more time editing the question.
Normal situation: as in the illustrated Missing Square puzzle, you do not know that your hypothesis is wrong. This is the main situation to discuss here (!).
So let's put focus on the normal situation.
SOLUTIONS/ATTENUATORS
The "XY problem" is a valid problem!
The Stack Exchange question is to show a problem. If my question helps to show that the real problem is my wrong hypothesis, it is OK! It is a first step, and perhaps I will not need any other questions after obtaining the correct hypothesis (and trying to solve by myself).
Example. See
about "self axis that fails"; the real problem is that @attribute::self does not exist, so it was a wrong hypothesis on the title of the question.
The help/mcve solution has limitations
: "How to create a Minimal, Complete, and Verifiable Example", can be used to avoid the XY problem.
But the cost of edit (time and attention expensive), and the perception that it is a kind of pollution in your text (a "bad marketing" for the question), are downsides.
It's correct also to simplify the problem and explain with more focus on the point.
Best practice
Train users of Stack Overflow to check if the simplification makes sense. Algorithm for a good question:
Try to create an MCVE.
If an MCVE is not practical, try at least to simplify.
Test, check for inconsistencies, simulate the reader& and review. Does your simplification produce something strange, change the context?
Review to avoid errors.
Listen to the comments about your question, and try to clarify, try to work editing the question if necessary: if there are people commenting, it is a notice that you can invest more time in your question.
The wrong hypothesis is not self-evident, but when we simplify, we amplify the wrong effects, and it becomes more evident.
PS: On the other hand, when we explain and show all the details, all the context, and check the real point, the assembly of the problem (like when using mcve), the inconsistencies also show with more evidence.
Negotiating a union contract...
The XY problem is relevant to the difference between "interest" based bargaining (X) and "position" based bargaining (Y).
X = the employee's overall take-home pay has been stagnant for the last several years, while their cost of living c the employee needs more take-home pay.
Y = picking "you will not raise parking fees" as a hill to die on / the only "solution" to X that the employee is willing to accept.
Aiming for Y (taking a position) is aiming for a very specific and limited solution to the problem (X).
It cuts the employee off from from the universe of solutions to the problem (X) by insisting that it only be solved in one very specific and limited way.
If that way (Y) is, for whatever reason, objectionable to the employer, then there will be a stalemate -- a period of time where there is no solution to X, where a solution has to be acceptable to both sides.
If the employee can aim for X instead of Y, then the universe of solutions remains open / unrestricted, and the employer can be recruited to help find possible solutions to X.
(Maybe it will turn out to be OK with the employee to raise parking rates, in exchange for a cost of living raise...)
This interest/position paradigm seems relevant to asking questions on SO, when OP asks for help making their position work.
Sometimes you can cut to X by simply asking: "Why are you trying to do this?"; But I wonder if sometimes, aiming for Y isn't just as valuable.
How many of us have ever tried to do something, just to see if we could?
Anyone here running their own DNS server with some specific type of software for that very reason? :-)
Might not be your best solution to X, but it's still interesting...
to answer this question.
Meta Stack Exchange works best with JavaScript enabledSystems of Linear Equations
Systems of Linear Equations
is an equation for a line.
A System of Equations is when we have two or more equations working together.
An example will help:
Example: You versus Horse
It's a race!
You can run 0.2 km every minute.
The Horse can run 0.5 km every minute. But it takes 6&minutes to saddle the horse.
How far can you get before the horse catches you?
We can make two equations (d=distance in km, t=time in minutes):
The Horse:
d = 0.5(t&6)
So we have a system of equations, and they are
It seems you get caught after 10 minutes ... you only got 2 km away.
Run faster next time.
So now you know what a System of Linear Equations is.
Let us continue to find out more about them ....
Now, a linear equation is not always in the form like y = 3x+2,
It can also be something like y & 3x = 2
Or &3x + y = 2
These are all the same linear equation
And there can be many ways to solve linear equations!
Let us see another example:
Example: Solve these two equations:
&3x + y = 2
The two equations are shown on this graph:
Our task is to find where the two lines cross.
OK, we can see where they cross, but let's solve it using Algebra!
Hmmm ... how should we solve this? There can be many ways! In this case
both equations have &y& so let's try
subtracting the second equation from the first:
x + y & (&3x + y) = 6 & 2
Which simplifies to:
x + y + 3x & y = 6 & 2
So now we know that x=1 is on both lines.
And we can find the matching value of y using either of the two original equations (because we know they have the same value at x=1). Let's use the first one (you can try the second one yourself):
And the solution is:
x = 1 and y = 5
And the graph shows us we are right!
Linear Equations
A Linear Equation can be in 2 dimensions ...
(such as x and y)
... or 3 dimensions
(such as x, y and z) ...
... or 4 dimensions ... or more!
(I just can't draw those)
And only simple variables. No x2, y3, &x, etc:
Linear vs non-linear
Common Variables
For the equations to &work together& they
share one or more variables:
A System of Equations has two or more equations in one or more variables
Many Variables
So a System of Equations could have
many equations and many variables.
Example: 3 equations in
3 variables
There can be
any combination:
2 equations in
3 variables,
6 equations in
4 variables,
9,000 equations in 567 variables,
When the number of equations is the same as the number of variables there is likely to be a solution. Not guaranteed, but likely.
In fact there are only three possible cases:
No solution
One solution
Infinitely many solutions
When there is no solution the equations are called &inconsistent&.
infinitely many solutions are
called &consistent&
Here is a diagram for 2 equations in 2 variables:
Independent
&Independent& means that each equation gives new information.
Otherwise they are &Dependent&.
Also called &Linear Independence& and &Linear Dependence&
2x + 2y = 6
Those equations are &Dependent&, because they are really the same equation, just multiplied by 2.
So the second equation gave no new information.
Where the Equations are True
The trick is to find where all equations are true at the same time.
True? What does that mean?
Example: You versus Horse
The &you& line is true all along its length (but nowhere else).
Anywhere on that line d is equal to 0.2t
at t=5 and d=1, the equation is true (Is d = 0.2t? Yes, as
1 = 0.2&5 is true)
at t=5 and d=3, the equation is not true (Is d = 0.2t? No, as 3 = 0.2&5 is not true)
Likewise the &horse& line is also true all along its length (but nowhere else).
But only at the point where they cross (at t=10, d=2) are they both true.
So they have to be true simultaneously ...
... that is why some people call them &Simultaneous Linear Equations&
Solve Using Algebra
Instead of
plotting a graph we can use
Example: You versus Horse
Let us solve it using Algebra.
The system of equations is:
d = 0.5(t-6)
In this case it seems easiest to set them equal to each other:
d = 0.2t = 0.5(t-6)
Expand 0.5(t-6):
0.2t = 0.5t - 3
Subtract 0.5t from both sides:
-0.3t = -3
Divide both sides by -0.3:
t = -3/-0.3 = 10 minutes
Now we know when you get caught!
Knowing t we can calculate d:
d = 0.2t = 0.2&10 = 2 km
And our solution is:
t = 10 minutes and d = 2 km
Algebra vs Graphs
Why use Algebra when graphs are so easy? Because:
More than 2 variables can't be solved by
a simple graph.
So Algebra comes to the rescue with two popular methods:
Solving By Substitution
Solving By Elimination
We will see each one, with examples in 2 variables, and in 3 variables. Here goes ...
Solving By Substitution
These are the steps:
Write one of the equations so it is in the style &variable = ...&
Replace (i.e. substitute) that variable in the other equation(s).
Solve the other equation(s)
(Repeat as necessary)
an example with 2 equations in 2 variables:
3x + 2y = 19
We can start with any equation and any variable.
Let's use the second equation and the variable &y& (it looks the simplest equation).
Write one of the equations so it is in the style &variable = ...&:
We can subtract x from both sides of x + y = 8 to get y = 8 - x. Now our equations look like this:
3x + 2y = 19
Now replace &y& with &8 - x& in the other equation:
3x + 2(8 - x) = 19
Solve using the usual algebra methods:
Expand 2(8-x):
3x + 16 - 2x = 19
3x-2x = x:
x + 16 = 19
And lastly 19-16=3
Now we know what x is, we can put it in the
y = 8 - x equation:
y = 8 - 3 = 5
And the answer is:
x = 3 and y = 5
Note: because there is a solution the equations are &consistent&
Check: why don't you check to see if x = 3 and y = 5 works in both equations?
Solving By Substitution:
3 equations in 3 variables
OK! Let's move to a longer example: 3 equations in 3 variables.
This is not hard to do... it
just takes a long time to do it!
z - 3y = 7
2x + y + 3z = 15
We should line up the variables neatly, or we may lose track of what we are doing:
can start with any equation and any variable. Let's use the first equation and the variable &x&.
Write one of the equations so it is in the style &variable = ...&:
Now replace &x& with &6 - z& in the other equations:
(Luckily there is only one other equation with x in it)
Solve using the usual algebra methods:
2(6-z) + y + 3z = 15 simplifies to y + z = 3:
Good. We have made some progress, but not there yet.
Now repeat the process, but just for the last 2 equations.
Write one of the equations so it is in the style &variable = ...&:
Let's choose the last equation and the variable z:
Now replace &z& with &3 - y& in the other equation:
Solve using the usual algebra methods:
-3y + (3-y) = 7 simplifies to -4y = 4, or in other words y = -1
Almost Done!
Knowing that y = -1 we can calculate that z = 3-y = 4:
And knowing that z = 4 we can calculate that x = 6-z = 2:
And the answer is:
x = 2, y = -1 and z = 4
Check: please check this yourself.
We can use this method for 4 or more equations and variables... just do the same steps again and again until it is solved.
Conclusion: Substitution works nicely, but does take a long time to do.
Solving By Elimination
Elimination can be faster ... but needs to be kept neat.
&Eliminate&
means to remove: this method works by removing variables until there is just one left.
The idea is that we can safely do these:
We can multiply an equation by a constant (except zero),
We can add (or subtract) an equation on to another equation
Like in these examples:
(We can also swap equations, so the 1st could become the 2nd, etc ... if that helps).
OK, time for a full example. Let's use the
2 equations in 2 variables example from before:
3x + 2y = 19
Very important to
keep things neat:
Now ... our aim is to eliminate a variable from an equation.
First we see there is a &2y& and a &y&, so let's work on that.
Multiply the second equation by 2:
Subtract the second equation from the first equation:
Yay! Now we know what x is!
Next we see the 2nd equation has &2x&, so let's halve it, and then subtract &x&:
Multiply the second equation by ½ (i.e. divide by 2):
Subtract the first equation from the second equation:
And the answer is:
x = 3 and y = 5
And here is the graph:
The blue line is where 3x + 2y = 19 is true
The red line is where x + y = 8 is true
At x=3, y=5 (where the lines cross) they are both true. That is the answer.
Here is another example:
2x - y = 4
6x - 3y = 3
Lay it out neatly:
Multiply the first equation by 3:
Subtract the second equation from the first equation:
0 - 0 = 9 ???
What is going on here?
Quite simply, there is no solution.
They are actually parallel lines:
And lastly:
2x - y = 4
6x - 3y = 12
Multiply the first equation by 3:
Subtract the second equation from the first equation:
Well, that is actually TRUE! Zero does equal zero ...
... that is because they are really the same equation ...
... so there are an Infinite Number of Solutions
They are the same line:
And so now we have seen an example of each of the three possible cases:
No solution
One solution
Infinitely many solutions
Solving By Elimination: 3 equations in 3 variables
Before we start on the next example, let's look at an improved
way to do things.
Follow this method and we are less likely to make a mistake.
First of all, eliminate the variables in order:
Eliminate xs first (from equation 2 and 3, in order)
then eliminate y (from equation 3)
So this is how we eliminate them:
We then have this &triangle shape&:
Now start at the bottom and work back up (called &Back-Substitution&)
(put in z to find y, then z and y to find x):
And we are solved:
ALSO, we will se that it is easier to do some of the calculations in our head, or on scratch paper, rather than always working within the set of equations:
x + y + z = 6
2y + 5z = -4
2x + 5y - z = 27
Written neatly:
First, eliminate x from 2nd and 3rd equation.
There is no x in the 2nd equation ... move on to the 3rd equation:
Subtract 2 times the 1st equation from the 3rd equation (just do this in your head or on scratch paper):
And we get:
Next, eliminate y from 3rd equation.
We could subtract 1½ times the 2nd equation from the 3rd equation (because 1½ times 2 is 3) ...
... but we can avoid
fractions if we:
multiply the 3rd equation by 2 and
multiply the
2nd equation by 3
and then do
the subtraction ... like this:
And we end up with:
We now have that &triangle shape&!
Now go back up again &back-substituting&:
We know z, so 2y+5z=-4 becomes 2y-10=-4, then 2y=6, so y=3:
Then x+y+z=6 becomes x+3-2=6, so x=6-3+2=5
And the answer is:
x = 5, y = 3 and z = -2
Check: please check for yourself.
General Advice
Once you get used to the Elimination Method it becomes
easier than Substitution, because you just follow the steps and the answers appear.
But sometimes Substitution can give a quicker result.
Substitution is often easier for small cases (like 2 equations, or sometimes 3 equations)
Elimination is easier for larger cases
And it always pays to look over the equations first, to see if there is an easy shortcut ... so experience helps.}

我要回帖

更多关于 for example和such as 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信