The study of psychological questionnaire using deep search analysis

Source: Internet
Author: User

Research background of psychological questionnaire analysis using deep Search

Yesterday my girlfriend sent me a psychological questionnaire for me to do. I have always sniffed at this psychological questionnaire: how a person's character can be determined by a few simple questions. But as a technician, I decided to use technical means to analyze the questionnaire and prove to my girlfriend that it lacks scientificity.

The original of the questionnaire is as follows

Interested friends can play ~

I would like to know the following questions:
1. Does the questionnaire have a loop? If there is a loop, you can prove that the questionnaire is irregular.
2. A answer is not impossible to achieve? Because of the 4 answers, only a answer has no inclination to be the same.
3. If a answer can be reached, then how many possibilities? How much is percentage?

Analysis

This questionnaire has features: Each topic corresponds to multiple options, and each option corresponds to a question or answer. From a person's answer to the path, in fact, this is a typical diagram structure.

In combination with the questions I want to know, there are several areas to consider:
1. No loop on the proof diagram
2. Using Dfs proof A is achievable
3. Count all possible results to figure out the percentage of a

Modeling

I'm going to use list mode to build the diagram

  @list= [    [1],    [2,3],    [3,4],    [4,5,6],    [5,6,7],    [6,7],    [7,8,9],    [8,9],    [9,Ten, One],    [Ten, One, A],    [ A, -],    [ -, -],    [ -, the],    [ the, -, -],    [ the, -],    [ -, -],    [ -, -, +, -],    [ -, +,' B '],    [ +,' C '],    [ A,' A '],    [ +,' D '],    [ A,' B '],    [' A ',' C ',' D ']  ]

The graphs have 0 to 22 nodes, plus a, B, C, D.
1. Because I do not want to deal with subscript, so the starting position of the figure, I set to 0;
2. The node of the graph, I simply use the index of the array to express;
3. Direct output of the answer, do not need to be placed in the node collection;

DFS diagram has no loops

The code is as follows:

 def Has_cycle? Recursion_stack = [false] * atCheck_cycle (0, Recursion_stack)End def Check_cycle (vertex, recursion_stack) Recursion_stack[vertex] =true  @list[Vertex].each Do|node|Next ifOver? (node)return true ifRecursion_stack[node] check_cycle (node, recursion_stack)EndRecursion_stack[vertex] =false  return falseEnd

over?The method is used to determine whether recursion is over.

def over?(point)  [‘A‘‘B‘‘C‘‘D‘].include?(point.to_s)end
    1. has_cycleTo determine if there is a loop, I will be a fully iterative node whether access to the information saved inrecursion_stack
    2. It calls the deep search algorithm to implement thecheck_cycle

The result of the operation isfalse

A can you get there? A if it can be reached, then how likely is a?
@result = []def dfs(node)  @list[node].eachdo |vertex|    if over?(vertex)      @result << vertex      next    end    dfs(vertex)  endend

Use a limited depth search to save the final results in @result and print out the results.

Def count_charactor (result, charactor)result. Count {|Item|Item= = Charactor}EndDfs0) puts"There's a total of%d possible answers."% @result. Size (' A '..' D '). To_a. each  Do|charactor| Puts"#{charactor}:%d possible, accounted for%f"% [Count_charactor (@result, charactor), Count_charactor (@result, charactor). To_f/@result.length]End

The results are as follows:

27860 可能的答案A:89600.321608B:33600.120603C:81200.291457D:74200.266332
Output to the 100 path of answer a
@i=0 def DFS (node, stack) Stack.push node@list[Node].each Do|vertex|ifOver? (vertex)@result<< VertexifVertex = =' A '        @i+=1Puts"The path to A is:"Puts Stack.join (" ,")End       Break if @i== -      Next    EndDFS (vertex, stack)EndStack.popEnd

Use a stack stack to save the path, and a point to output all the results

Summarize

The application of the graph algorithm is very extensive and deserves further study. Sometimes the problem of abstracting real-time problems into graphs allows us to look at issues from a different perspective. Furthermore, the ruby algorithm of implementing graph is very simple. dfsthan bfs simple, but received the limit of the program stack. But it is more suitable for this program.

The study of psychological questionnaire using deep search analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.