Category Archives: How to Fix

go :Multiple-value strconv.Atoi() (int, error) in single-value context

code

devicePositionType := strconv.Atoi(info[0]["device_position_type"].(string))

report errors

Multiple-value strconv.Atoi() (int, error) in single-value context

This is because the returned data has two parameters, and only one is defined in the code, so the code needs to add another parameter, which is generally defined as err

devicePositionType,err := strconv.Atoi(info[0]["device_position_type"].(string))

But I can’t use err. If I don’t use err, go will still report an error

Unused variable 'err'

So it needs to be written like this

devicePositionType,_ := strconv.Atoi(info[0]["device_position_type"].(string))

It means that I will not call it later, and I have defined two parameters and will not report an error

Null hypothesis

Summary of null hypothesis

Zero hypothesis, H0 is a generally accepted fact; it is contrary to the alternative hypothesis. Researchers are committed to rejecting, abolishing or refuting the null hypothesis. The researchers put forward an alternative hypothesis that they thought explained a phenomenon and then tried to reject the null hypothesis.

The famous zero hypothesis in history is that the earth is flat. Later scientists tried to prove that the hypothesis was wrong under this assumption which was generally considered correct in the early stage.

Accordingly, its alternative hypothesis is that the earth is round.

Why zero (null)

In this case, the word “null” means that researchers are trying to nullify such a generally accepted fact. This does not mean that the assumption itself is null! (the word should be called “nullifiable hypothesis” to reduce confusion).

Null means: nullifiable. Can, or allowed to be nullified

The short answer is that the null hypothesis is the research method needed as a scientist; it’s part of the scientific process. Science uses a series of processes to prove or disprove theories to ensure that no new hypothesis is flawed. Including null and void assumptions is a safeguard to ensure that your research is flawless. It is considered very bad by the scientific community not to include zero hypothesis in your research. If you are going to prove an alternative hypothesis without considering it, you are likely to let yourself fail. At least, your experiment may not be taken seriously.

give an example

Long ago, people believed that the world was flat.
Zero hypothesis H0: the world is flat.
Alternative hypothesis H1: the world is round.
Several scientists, including Copernicus, began to refute the null hypothesis. This eventually leads to the rejection of null hypothesis and the acceptance of alternative hypothesis. Most people accepted it! What would have happened if Copernicus had not refuted it but only proved a substitute? No one will listen to him. In order to change people’s minds, he must first prove that they are wrong.

How to put forward zero hypothesis

Example question: the researchers believe that patients with knee surgery would have a longer recovery period if they received physical therapy twice a week instead of three times a week. The average recovery time was 8.2 weeks.

Step 1: find out the hypothesis from the question. This assumption is usually hidden in the question, sometimes a statement of what you want to happen in the experiment. The assumption of the above question is “I expect an average recovery period of more than 8.2 weeks.”
Step 2: transform the hypothesis into mathematics. Remember that the average is sometimes written as μ.

H1:μ> 8.2

Subdivided into H1 (hypothesis): μ (mean) & gt; (greater than) 8.2

Step 3: explain what will happen if the assumption fails. If the recovery time does not exceed 8.2 weeks, there are only two possibilities, that is, the recovery time is equal to or less than 8.2 weeks.

H0:μ≤8.2

It is decomposed again to H0 (null hypothesis): μ (mean value) ≤ (less than or equal to) 8.2

But what happens if researchers don’t know?

Sample question: researchers are studying the impact of aggressive exercise on patients undergoing knee surgery. Treatment is likely to shorten the recovery time, but it may also make the treatment worse. The average recovery time was 8.2 weeks.

Step 1: explain what happens if the experiment doesn’t make any difference. It’s a zero hypothesis – nothing will happen. In this experiment, if there was no response, the recovery time would remain at 8.2 weeks.

H0:μ= 8.2

That is, H0 (null hypothesis): μ (mean) = (equal to) 8.2

Step 2: find alternative hypotheses. The substitution hypothesis is opposite to the null hypothesis. In other words, what happens if our experiment does something?

H1:μ≠8.2

That is H1 (alternate hypothesis): μ (average) ≠ (not equal to) 8.2

This is how to state the null hypothesis!
https://www.statisticshowto.datasciencecentral.com/probability-and-statistics/null-hypothesis/

matplotlib 1.3.1 requires nose, which is not installed. matplotlib 1.3.1 requires tornado, which is

When installing tensorflow, execute the command

$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

Reference:
1 http://www.tensorfly.cn/tfdoc/get_ started/os_ setup.html

The error is as follows:

Matplotlib 1.3.1 requirements nose, which is not installed.
Matplotlib 1.3.1 requirements tornado, which is not installed.
installing collected packages: numpy, six, tensorflow
found existing installation: numpy 1.8.0rc1
to solve the problem, the implementation is as follows:

  sudo easy_install nose
  sudo easy_install tornado

Android:Field can be converted to a local varible.

background

It’s been a while since Android studio was used to develop Android. Occasionally, as has a yellow highlight on some private variables field can be converted to a local variable . I still don’t want to see this yellow highlight for some obsessive-compulsive disorder. Baidu did not find any useful information, or Google search to find some answers.

analysis

The complete description of field can be converted to a local variable is (hand play only): field can be converted to a local variable :

This inspection searches for redundant class fields that can be replaced with local variables,if all local usages of a field are preceded by assignments to that field,the field can be removed and its usages replaced with local variables.

This means that it is detected that this variable can be replaced by a local variable. It is recommended to delete it and write it as a local variable.

Solution

Delete the sentence private XXX; and declare and instantiate it directly where it is used.
In Android studio for Mac , you can use the shortcut key Alt + enter to quickly convert local variables.

PS: you still need better English. In fact, you can understand it by reading the instructions. You don’t need to search in this way.

Mac: how to show hidden files under Apple Mac operating system

There are many ways to display hidden files in MAC,

1. Terminal

The simplest is to enter commands on the MAC terminal.
Show hidden files (note space and case):

defaults write com.apple.finder AppleShowAllFiles -bool true 

or

defaults write com.apple.finder AppleShowAllFiles YES

Do not show hidden files:

defaults write com.apple.finder AppleShowAllFiles -bool false 

or

defaults write com.apple.finder AppleShowAllFiles NO

After input, click enter, then exit the terminal directly and restart finder.
Restart the finder: first force to exit the finder, and then restart the finder.

2. Shortcut key

    Press Shift + cmmand +. On the keyboard to hide the directory where the file is located, and then you can see that all the hidden files in the hidden folder with a small dot in front or the files with light blue are hidden files. In this way, you can view the hidden directory. To restore the hidden file, press Shift + cmmand +. Again to restore the hidden state of the file, as shown in Figure 2. The hidden file is no longer visible.

Sigmoid function

Sigmoid function is a mathematical function with beautiful S-shape curve, which is widely used in logistic regression and artificial neural network. The mathematical form of sigmoid function is:
0

f(x)=11+e−x

The function image is as follows:

It can be seen that sigmoid function is continuous, smooth, strictly monotone, and symmetric with (0,0.5) center, which is a very good threshold function.

When x approaches negative infinity, y approaches 0; when x approaches positive infinity, y approaches 1; when x = 0, y = 0.5. Of course, when x goes beyond the range of [- 6,6], the value of the function basically does not change, and the value is very close, so it is generally not considered in the application.

The range of sigmoid function is limited between (0,1). We know that [0,1] corresponds to the range of probability value, so sigmoid function can be associated with a probability distribution.

The derivative of sigmoid function is its own function, that is

f′(x)=f(x)(1−f(x))

The calculation is very convenient and time-saving. The derivation process is as follows:
according to the commonly used derivation formula,
is obtained

f′(x)=(−1)(1+e−x)−2(0+(−1)e−x)=e−x(1+e−x)2=e−x1+e−x11+e−x

And:

1−f(x)=1−11+e−x=e−x1+e−x

Therefore,

f′(x)=f(x)(1−f(x))

.

Although sigmoid function has good properties, it can be used in classification problems, such as the classifier of logistic regression model. But why choose this function? In addition to the above mathematical easier to deal with, there are its own derivation characteristics.
For the classification problem, especially for the binary classification problem, it is assumed that the distribution obeys Bernoulli distribution. The PMF of Bernoulli distribution is:
0

f(x|p)=px(1−p)1−x

According to《

The general expression framework of the family of exponential distributions is as follows

f(x|θ)=h(x)exp{η(θ)T(x)−A(θ)}

The Bernoulli distribution is transformed into:

f(x|p)=exp{ln(p1−p)x+log(1−p)}

Among them:

θ=p

h(x)=1

T(x)=x

η(θ)=lnp1−p

A(θ)=−ln(1−p)

. Therefore, Bernoulli distribution also belongs to exponential distribution family.

We can deduce it

p

And η (θ):
the relationship between η (θ) and η (θ) was analyzed

η(θ)=lnp1−p

Then:

−η(θ)=−lnp1−p=ln1−pp=ln(1p−1)

The results are as follows

e−η(θ)=1p−1

1+e−η(θ)=1p

p=11+e−η(θ)

This is the form of sigmoid function.

solve org.apache.ibatis . binding.BindingException : invalid bound statement (not found)

org.apache.ibatis . binding.BindingException : invalid bound statement (not found) problem, that is, there is a problem when the Dao interface and mapper configuration file are mapped and bound in mybatis. In short, the interface and XML are either not found, or they are found but not matched.

The screenshot shows the common reasons for searching in the network

According to the revision, the problem still exists. Finally, it took a lot of effort to find the root of the problem. Dao interface is inconsistent with the file name of XML.

The interface name and interface file name are both department Dao, and the configuration file name is DeparmentDao.xml It took a lot of effort to look up a t for both names. After modification, everything will be normal.

This is a point as like as two peas. Remember that the name of the interface name and Mybatis must be exactly the same.

How to use matlab to solve equation

How to use matlab to solve equation

1. Preface

As one of the three major mathematical software, Matlab is the best in numerical calculation. Solving equations is the most basic and common problem in engineering study and engineering calculation. It is very important to master the method of solving equations with modern tools to improve our engineering literacy. Therefore, this paper will introduce the method of solving equations in MATLAB.

2. Usage

solving process

2.1 – indicated variables

Tell the computer the variables contained in the equation, including parameters and unknown variables. For example, the equation to be solved is: obviously, there are symbolic variables a, B, C and X in the equation, so the writing method of this step is:

syms a b c x  

 

2.2 specify equations, unknowns and constraints (not required)

If there is more than one equation,

eqns put it in [] and separate it with a comma. For example:
vars unknowns to be solved
Names value (not required) Names: “return conditions” returns the general solution with parameters. ” If ‘true’ is returned and ‘false’ is not, a special solution is given;
Name: ‘ignoreanalytical constraints’ is the simplest form of the solution given. ‘true ‘is yes and’ false ‘is no
Name:’ principalvalue ‘only gives one solution. False is to return all solutions, true is to return only one solution;
Name: ‘real’ only returns real solutions

2.3 obtain the solution of the equation

If there are multiple functions, the solution is stored as a structure.

 

3. Specific examples

3.1 = general solution of sin (x) = 1

 

Specific code:

syms x  [x,params,conds]=solve(sin(x)==1,’ReturnConditions’, true) 

 

result

solx =pi/2+2*pi*k  params =k  conds =in(k,’integer’)

 

It can be seen that the general solution of the equation is as follows:

 

3.2 solve the following equation:

code:

syms a b c y x [x,y]=solve([a*x^2+b*y+c==0,a*x+2*y==4],[x,y])

 

result:

x =  ((a*b)/4-(-(a*(- a*b^2+32*b +16*c))/16)^(1/2))/a  ((a*b)/4+(-(a*(- a*b^2+32*b +16*c))/16)^(1/2))/a   y =  (-(a*(- a*b^2+32*b +16*c))/16)^(1/2)/2-(a*b)/8+2  2-(-(a*(- a*b^2+32*b +16*c))/16)^(1/2)/2-(a*b)/8

 

Namely:

Matlab matrix transpose function

For the known matrix A, matlab provides us with two transpose operations.

A. ‘non conjugate transpose

A ‘conjugate transpose

When a is a real matrix, they are the same

Simply conjugate with: conj ()

Simple transpose: transpose ()

example:

 

  a =

        12.0000                  0 + 2.0000i         5.0000          
        0                             5.0000               4.0000 

>> a’

             ans =

                      12.0000                  0          
                      0 – 2.0000i              5.0000          
                      5.0000                    4.0000         

>> a.’

           ans =

                   12.0000                  0          
                  0 + 2.0000i              5.0000          
                  5.0000                    4.0000

Attributeerror: module “Seaborn” has no attribute “lineplot”

Contents of articles

Preface text

preface

When drawing the diagram, I learned a new library and encountered bugs, but fortunately, I found a solution

text

The specific problem is that the version is wrong, and 0.9 is OK. You can check the version through the command:
PIP freeze | grep Seaborn
or
PIP3 freeze | grep Seaborn
you can check the version through CONDA
CONDA install - C Anaconda Seaborn = 0.9.0
for details Some packages are not included in the default channels of CONDA, such as cudatoolkit-8.0, cudnn, and so on. At this time, you only need to add – C Anaconda after the CONDA install command
or pip:
PIP3 install Seaborn = = 0.9.0
to install the corresponding version
it is recommended to use pip, and the matching image is very fast. There seems to be no network error on the image of CONDA Tsinghua.
Then, there may be version errors in Python 3.6. The following lists the libraries with version problems that I encountered, and gives the possible version
numpy = = 1.15.0
SciPy = = 1.0.0
panda = = 1.0.0

Latex sets page margin, page size, page margin and geometry macro package

Many latex templates have set the margins of the page, so you don’t need to modify them. But sometimes you need to set the margins by yourself. Looking up the relevant information, we find that using the geometry macro package can easily adjust the margins.

\usepackage{geometry}

\geometry{a4paper,scale=0.8}

The above command sets the paper as A4, and the proportion of the page center to the page length is 80%; scale can also be changed to ratio, indicating the proportion of the page margin to the page length. The macro package can also set the top, bottom, left and right margins of the page, for example:

\geometry{a4paper,left=2cm,right=2cm,top=1cm,bottom=1cm}

Greek alphabet pronunciation table and its latex command

Latin alphabet is 26, Greek alphabet is 24, pronunciation is their respective latex form, capital letter is its lowercase latex initial capitalized form, such as(

Δ

When Western mathematicians deduce mathematical theorems, they still use Greek letters which are not easy to write and remember. This shows the great influence of the Renaissance and Greek mathematics on later generations. Pay attention to the distinction

Δ

(pronounced Delta for increment) and

(it’s pronounced nabla, which means differential. It doesn’t belong to the Greek alphabet. It’s just a sign for differential operator.)

lowercase uppercase latex

α

A

\alpha
β

B

\beta
γ

Γ

\gamma

δ

Δ

\delta

ϵ

E

\epsilon
ζ

Z

\zeta
ν

N

\nu
ξ

Ξ

\xi

ο

O

\omicron
π

Π

\pi

ρ

P

\rho
σ

Σ

\sigma

η

H

\eta
θ

Θ

\theta

ι

I

\iota
κ

K

\kappa
λ

Λ

\lambda

μ

M

\mu
τ

T

\tau
υ

Υ

\upsilon

ϕ

Φ

\phi,(

φ

\varphi

χ

X

\chi
ψ

Ψ

\psi

ω

Ω

\omega