Exemplars and Simple Segregation
No preview image
Model was written in NetLogo 5.2.0
•
Viewed 535 times
•
Downloaded 34 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
extensions [table matrix] globals [reference-system lefty-system righty-system ;; **slider** individual-percent ; how much individual turtles vary from their reference systems ; Each group, lefties and righties, has a mean for their systems, individual-percent ; is used to build in individual variation. ; leaders-talk-with-other-leaders ;; This is a counter, for counting the ; number of times a leader of one breed talks to a leader of the other breed. ; We have decided for now not to tract this, but are leaving in the code ; to do so, if we choose to uncomment it. ;; **slider** dasd the standard deviation, applied to generating individual examples current-vowel lefty-confusions righty-confusions myticks dateandtime bob carol ted alice bob_under_score ] breed [lefties lefty] breed [righties righty] turtles-own [exemplars ;; The history list of what the turtle has heard or thinks it has heard, ;; of length count-exemplars (slider on the Interface) ;; exemplars, a turtles variable, holds a table whose keys are the vowel IDs and ;; whose values are lists of 2-tuple lists, of first and second formant pairs. ;; After initialization, we assume that the ordering of the pairs is chronological, ;; with the oldest at the front, the youngest at the end. exemplar-means exemplar-ratios leader? ;; Is this turtle a leader? category-list ;; Is a list of pairs (lists) in which the first member is the signal ; received and the second is the guess. So, when they agree, the agent has ; guessed correctly, and if not, not. radius-mean ; Gets the value lefty-radius-mean, if the turtle is a lefty, and ; righty-radius mean, if the turtle is a righty. These values are given as sliders ; on the interface. myneighbors ; other turtles in-radius get-a-radius ] to setup clear-all if file-exists? "run-pretties.txt" [file-delete "run-pretties.txt"] if file-exists? "run-uglies.txt" [file-delete "run-uglies.txt"] if file-exists? "exemplar-means.csv" [file-delete "exemplar-means.csv"] if file-exists? "confusions.csv" [file-delete "confusions.csv"] make-reference-system set lefty-system make-group-system(reference-system)(percentshift)("down") set righty-system make-group-system(reference-system)(percentshift)("up") if (Scenarios = "User Interface") [ set lefty-system make-group-system(reference-system)(percentshift)("down") set righty-system make-group-system(reference-system)(percentshift)("up") ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; end of "User Interface" ;;;;;;;;;;;;;;;;;;;;; ; if (Scenarios = "Zero Model") ; [ ; set individual-percent 0.05 ; set percentshift 0.0 ; set lefty-system make-group-system(reference-system)(percentshift)("down") ; set righty-system make-group-system(reference-system)(percentshift)("up") ; ;set LeaderNetworks false ; set numberofleftyleaders 0 ; set numberofrightyleaders 0 ; set lefty-radius-mean 10 ; set righty-radius-mean 10 ; ] ;; Create confusion tables, one for lefties, one for righties let num-vowels length table:keys reference-system set lefty-confusions matrix:make-constant num-vowels num-vowels 0 ; show matrix:pretty-print-text lefty-confusions ; show matrix:dimensions lefty-confusions set righty-confusions matrix:make-constant num-vowels num-vowels 0 ;; Create the lefties on the left and the righties on the ... right! ;; We are aware that unless we change the world size from the default, ;; there are more righties than lefties. ask patches with [pxcor < 0] [sprout-lefties 1 [set radius-mean lefty-radius-mean] ] ask patches with [pxcor >= 0] [sprout-righties 1 [set radius-mean righty-radius-mean] ] ask lefties [set exemplars make-some-exemplars(count-exemplars)(lefty-system)(individual-percent) make-exemplar-means set shape "square" ;set color newcolor(mean exemplars) ] ;; ok to here ask righties [set exemplars make-some-exemplars(count-exemplars)(righty-system)(individual-percent) make-exemplar-means set shape "square" ;set color newcolor(mean exemplars) ] ask turtles [ make-exemplar-ratios set leader? false set category-list [] let lowhi set-color set color scale-color green get-vowel-value(VowelFollowed)(FormantFollowed) first lowhi last lowhi ] ask turtles [ set myneighbors other turtles in-radius get-a-radius ] create-leaders ask lefties with [leader? = true] [create-links-with other n-of ((random lefty-leader-connectivity) + 1) lefties with [leader? = true]] ask righties with [leader? = true] [create-links-with other n-of ((random righty-leader-connectivity) + 1) righties with [leader? = true]] reset-ticks if file-exists? "exemplar-means.csv" [file-delete "exemplar-means.csv"] ;; Print the headers for the file: file-open "exemplar-means.csv" ;file-print (word "+++++ " ticks " +++++") let toPrint (word "tick,Vowel,mean_turtles_first,mean_turtles_second,var_turtles_first,var_turtles_second") set toPrint (word toPrint ",mean_lefties_first,mean_lefties_second,mean_righties_first,mean_righties_second,variance_lefties_first") set toPrint (word toPrint ",variance_lefties_second,variance_righties_first,variance_righties_second") set toPrint (word toPrint ",mean_leaders_lefties_first,mean_leaders_lefties_second,mean_leaders_righties_first,mean_leaders_righties_second") set toPrint (word toPrint ",var_leaders_lefties_first,var_leaders_lefties_second,var_leaders_righties_first,var_leaders_righties_second") file-print toPrint file-close-all ;; Now write the data: record-breed-formant-stats set dateandtime date-and-time end ;; End of setup ;;;;;;;;;;;;;;;;;;;; end of setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to set-scenarios ; if (Scenarios = "Zero Model") ; [ ; set individual-percent 0.05 ; set percentshift 0.0 ;; set lefty-system make-group-system(reference-system)(percentshift)("down") ;; set righty-system make-group-system(reference-system)(percentshift)("up") ; ;set LeaderNetworks false ; set numberofleftyleaders 0 ; set numberofrightyleaders 0 ; set lefty-radius-mean 10 ; set righty-radius-mean 10 ; ] if (Scenarios = "Base Model") [set reps 40000 set numberofleftyleaders 80 set numberofrightyleaders 80 set leaderschange true set dasd 4.50 set count-exemplars 100 set leader-effect round (100 * 60 / count-exemplars) set leader-leader-effect false set pleaderleader 0 set lefty-radius-mean 5 set righty-radius-mean 5 set lefty-leader-connectivity 5 set righty-leader-connectivity 5 set percentshift 0.10 set bigotry 0 set individual-percent 0.05 ] end ;;;;;;;;;;;;;;; end of set-scenarios ;;;;;;;;;;;;;;;;;;;;;;; to create-leaders let lefty-leaders n-of numberofleftyleaders lefties ask lefty-leaders [set shape "dot" set leader? true] let righty-leaders n-of numberofrightyleaders righties ask righty-leaders [set shape "dot" set leader? true] end to go ask turtles [ if (leaderschange or leader? = false) [ let withwhom nobody ifelse (leader? = true and random-float 1 <= pleaderleader) ; and leaderstalkleaders) [set withwhom one-of link-neighbors] [ifelse ((random-float 1) < bigotry) [let mybreed [breed] of self set withwhom one-of myneighbors with [breed = mybreed]] [set withwhom one-of myneighbors]] if withwhom != nobody [ ;; So we have somebody ; Initialize utterace let utterance 0 ;; Ask the interlocutor to say something and you record it: ask withwhom [set utterance utter-vowel] ;; Key: this is the interlocutor speaking. ;; utterance is now a 3-tuple list. First is the actual vowel, second is the first formant, third is the second formant map-utterance-to-vowel(utterance) ;; Find out what vowel you think you heard. Get the ID let daVowel get-last-mapped-vowel set current-vowel daVowel ;; instance is just the formants, of what you heard. It's a 2-list, first and second formants. ;; daVowel is what you think you heard. let instance (list item 1 utterance item 2 utterance) ;; add-exemplar-instance(current-vowel)(instance) ;; Now the new basic logic==> ;; (1) ;; (not leader) and (interlocutor is a leader) and (you have the same breed) if (leader? = false and [leader? = true] of withwhom and [breed] of withwhom = [breed] of self) [ask self [repeat leader-effect [add-exemplar-instance(current-vowel)(instance)]] ] ;; (2) ;; (leader) and (interlocutor is a leader) and (you have the same breed) if (leader? = true and [leader? = true] of withwhom and [breed] of withwhom = [breed] of self) [ifelse leader-leader-effect = true ;; Leaders act as break on other leaders: [ask self [repeat leader-effect [add-exemplar-instance(current-vowel)(instance)]] ] ;; Else do a normal accommation, not a leader accommodation, since you are a leader. ;; Immediately below: leader on leader becomes normal accommodation: [ask self [add-exemplar-instance(current-vowel)(instance)] ] ] ;; (3) ;; (not leader) and (interlocutor is not a leader) if (leader? = false and [leader? = false] of withwhom) ;; You are both not leaders, do a normal accommodation [ask self [add-exemplar-instance(current-vowel)(instance)]] ;; (4) ;; (I am a leader) and ((interlocutor is not a leader) or ((is a leader) and (of a different breed from me))) if (leader? = true and (([leader? = false] of withwhom) or ([leader? = true] of withwhom and [breed] of withwhom != [breed] of self))) ;; If your are a leader and either (a) your interlocutor is not a leader or (b) it is, but it's a leader of another breed ;; then to a normal adjustment/accommodation [ask self [add-exemplar-instance(current-vowel)(instance)]] ;; Update the stats. make-new-vowel-mean(current-vowel) make-new-vowel-ratio(current-vowel) ] ;; if withwhom != nobody ] ;; if (leaderschange or leader? = false) ] ;; end of ask turtles set myticks (myticks + 1) ;print myticks ;] ;; end of repeat let lowhi set-color ask turtles [set color scale-color green get-vowel-value(VowelFollowed)(FormantFollowed) first lowhi last lowhi] ; ifelse myticks mod 10 = 0 ; [tick ; set myticks 0 ; ;print "ticking" ; ] ; [;print "not ticking" ; ] ; set myticks (myticks + 1) ; if ticks > 5 ; [let file (word date-and-time ".csv") ; export-all-plots file ; print "Stopping." ; stop] tick set dateandtime date-and-time if ticks mod 100 = 0 [ file-open "run-pretties.txt" file-print (word "+++++ " ticks " +++++") file-print matrix:pretty-print-text lefty-confusions file-print matrix:pretty-print-text righty-confusions file-close-all file-open "confusions.csv" ;file-print (word "+++++" ticks "+++++") ;file-print (word "******** lefty-confusions ***********") dumpmatrixcsv lefty-confusions "left" ;file-print (word "******** righty-confusions ***********") dumpmatrixcsv righty-confusions "right" file-close-all record-uglies ;; Now record the exemplar means for lefties and righties. record-breed-formant-stats ] end ;; End of go to-report set-color let da-formant-value get-formant-value(VowelFollowed)(FormantFollowed) let displacement (0.2 + percentshift) let lowscale da-formant-value / 2 ;(1 - displacement) * da-formant-value let hiscale da-formant-value * 1.5 ;(1 + displacement) * da-formant-value report (list lowscale hiscale) end to add-exemplar-instance [key pair] let daExemplars table:get exemplars key set daExemplars but-first daExemplars set daExemplars lput pair daExemplars table:put exemplars key daExemplars end ;to test ;; set bob make-group-system(reference-system)(0.05)("up") ;; ;show bob ;; ;show uniform-interval(100)(0.05) ;; set lefty-system make-group-system(reference-system)(0.05)("down") ;; show lefty-system ; ; let daResult 0 ; ask one-of turtles [set daResult utter-vowel] ; show daResult ; print "Yo!" ; ask one-of turtles [map-utterance-to-vowel(daResult) ; ; show category-list ; ;; Find out what vowel you think you heard. Get the ID ; let daVowel get-last-mapped-vowel ; show daVowel ; let daExemplars table:get exemplars daVowel ; show daExemplars ; set daExemplars but-first daExemplars ; set daExemplars lput (list item 1 daResult item 2 daResult) daExemplars ; show daExemplars ; table:put exemplars daVowel daExemplars ; show table:get exemplars daVowel ; show table:get exemplar-means daVowel ; show table:get exemplar-ratios daVowel ; make-new-vowel-mean(daVowel) ; make-new-vowel-ratio(daVowel) ; show table:get exemplar-means daVowel ; show table:get exemplar-ratios daVowel ; ] ; ;; update as appropriate ; ;end to-report get-last-mapped-vowel report last last category-list end to map-utterance-to-vowel [daUtterance] ;; New version. Looks at ratio of formants. ;; In the turtle context. The turtle is listening to the interlocutor. ;; The turtle needs to guess which vowel it heard. It then maps and ;; records daUtterance. ;; daUtterance is [let daFirst item 1 daUtterance let daSecond item 2 dautterance let perceptual-ratio (daSecond / daFirst) let distances [] foreach table:keys exemplar-ratios [ set distances lput abs((table:get exemplar-ratios ?) - perceptual-ratio) distances ] let daMin min distances let daMinValue (position daMin distances + 1) set category-list lput (list item 0 daUtterance daMinValue) category-list ;;; Steve on 2014-11-20: if length category-list > 5 ; 2015-02-06: A bit puzzling but seems innocuous. Have to limit it somehow. [set category-list but-first category-list] let speaker-vowel-index (item 0 daUtterance - 1) let hearer-vowel-index (daMinValue - 1) ifelse breed = lefties [matrix:set lefty-confusions speaker-vowel-index hearer-vowel-index (1 + matrix:get lefty-confusions speaker-vowel-index hearer-vowel-index) ] [matrix:set righty-confusions speaker-vowel-index hearer-vowel-index (1 + matrix:get righty-confusions speaker-vowel-index hearer-vowel-index)] end to-report utter-vowel ; To allow utterance alternatives in the future: ;if concept-method = "hybrid" ;[report utter-vowel-hybrid] ;if concept-method = "pure exemplar" ;[report utter-vowel-pure-exemplar] report utter-vowel-hybrid end to pp print matrix:pretty-print-text lefty-confusions print matrix:pretty-print-text righty-confusions end to-report utter-vowel-hybrid ;; For turtles. ;; Reports a list whose first value is the key of the chosen ;; vowel, whose second value is its perturbed first formant, ;; and whose third value is its perturbed second formant. ;; ;; Find out how many vowels there are. let num-vowels length table:keys exemplar-means ;; Pick a vowel at random, uniformly. let the-vowel ((random num-vowels) + 1) let daFormants table:get exemplar-means the-vowel let daFirst first daFormants let daSecond last daFormants let daFirstPerturbed max (list 0.1 random-normal daFirst dasd) let daSecondPerturbed max (list 0.1 random-normal daSecond dasd) report (list the-vowel daFirstPerturbed daSecondPerturbed) end to-report utter-vowel-pure-exemplar ;; Find out how many vowels there are. let num-vowels length table:keys exemplar-means ;; Pick a vowel at random, uniformly. let the-vowel ((random num-vowels) + 1) let daFormants get-pure-exemplar the-vowel 10 let daFirst first daFormants let daSecond last daFormants let daFirstPerturbed max (list 0.1 random-normal daFirst dasd) let daSecondPerturbed max (list 0.1 random-normal daSecond dasd) report (list the-vowel daFirstPerturbed daSecondPerturbed) end to-report get-a-radius report (random-exponential radius-mean) + 1 end to-report mean-exemplars ;; sok 2015-06-19 This reporter no longer works and is isolated, ;; not used. let lefty-mean-accum [] ask lefties [ set lefty-mean-accum fput mean exemplars lefty-mean-accum ] let righty-mean-accum [] ask righties [ set righty-mean-accum fput mean exemplars righty-mean-accum ] report (list mean lefty-mean-accum variance lefty-mean-accum mean righty-mean-accum variance righty-mean-accum) end to-report newcolor [myscore] report max (list 0 (((floor (myscore / 10 )) * 10) + 5)) end to make-reference-system set reference-system table:make table:put reference-system 1 (list 299 2190) table:put reference-system 2 (list 364 2260) table:put reference-system 3 (list 481 1980) table:put reference-system 4 (list 750 1250) table:put reference-system 5 (list 377 1400) table:put reference-system 6 (list 290 630) table:put reference-system 7 (list 392 690) table:put reference-system 8 (list 502 790) end to-report make-group-system [ref daPercent upordown] let new-system table:make foreach table:keys ref [ let daEntry table:get ref ? let first-formant first daEntry let second-formant last daEntry ; let new-first-formant uniform-interval(first-formant)(daPercent) ; let new-second-formant uniform-interval(second-formant)(daPercent) let new-first-formant fixed-offset(first-formant)(daPercent)(upordown) let new-second-formant fixed-offset(second-formant)(daPercent)(upordown) table:put new-system ? (list new-first-formant new-second-formant) ] report new-system end to-report fixed-offset [formant daPercent upordown] if upordown = "down" [report formant * (1 - daPercent)] if upordown = "up" [report formant * (1 + daPercent)] end to-report uniform-interval [daCenter daPercent] ; daPercent should be a low number, such as 0.1 let low daCenter - (daCenter * daPercent) let high daCenter + (daCenter * daPercent) report (random-float (high - low)) + (daCenter - (daCenter * daPercent)) end to-report make-some-exemplars [n ref-table daPercent] ;let toreport [] let my-table table:make foreach table:keys ref-table [ let daList [] let daEntry table:get ref-table ? let first-formant first daEntry let second-formant last daEntry let new-first-formant 0 let new-second-formant 0 repeat n [ set new-first-formant uniform-interval(first-formant)(daPercent) set new-second-formant uniform-interval(second-formant)(daPercent) set daList fput (list new-first-formant new-second-formant) daList ] table:put my-table ? daList ] report my-table end to make-exemplar-means set exemplar-means table:make foreach table:keys exemplars [ make-new-vowel-mean(?) ] end to make-new-vowel-mean [daVowel] let llist [] let hlist [] let theItems table:get exemplars daVowel let n length theItems foreach n-values n [?] [ set llist fput (first item ? theItems) llist set hlist fput (last item ? theItems) hlist ] table:put exemplar-means daVowel (list mean llist mean hlist) end to make-exemplar-ratios set exemplar-ratios table:make foreach table:keys exemplar-means [ make-new-vowel-ratio(?) ] end to make-new-vowel-ratio [daVowel] ; foreach table:keys exemplar-means [ ; let daValues table:get exemplar-means ? ; let daFirst first daValues ; let daSecond last daValues ; table:put exemplar-ratios ? (daSecond / daFirst) ; ] let daValues table:get exemplar-means daVowel let daFirst first daValues let daSecond last daValues table:put exemplar-ratios daVowel (daSecond / daFirst) end ;to debug ; foreach table:keys exemplar-means [ ; print ? ; ] ;end to-report get-vowel-variance [LorR vNum fNum] ;; LorR should be lefties or righties ;; vNum is 1, 2, ... 8 the vowel number ;; fNum should be 1, 2, whatever, the formant number let daList [] ask LorR [ set daList lput (item (fNum - 1) table:get exemplar-means vNum) daList ] report variance daList end to-report get-vowel-value [vNum fNum] ;; vNum is 1, 2, ... 8 the vowel number ;; fNum should be 1, 2, whatever, the formant number report item (fNum - 1) table:get exemplar-means vNum end to-report get-vowel-means [LorR vNum fNum] ;; LorR should be lefties or righties ;; vNum is 1, 2, ... 8 the vowel number ;; fNum should be 1, 2, whatever, the formant number let daList [] ask LorR [ set daList lput (item (fNum - 1) table:get exemplar-means vNum) daList ] ; let daList [] ; ifelse LorR = "lefties" ; [ ask lefties [let daPair table:get exemplar-means daVowel ; let daFirst first daPair ; set daList lput daFirst daList ; ] ; ] ; [ ; ask righties [let daPair table:get exemplar-means daVowel ; let daFirst first daPair ; set daList lput daFirst daList ; ] ; ] report mean daList end to-report get-vowel-means-first [LorR daVowel] let daList [] ifelse LorR = "lefties" [ ask lefties [let daPair table:get exemplar-means daVowel let daFirst first daPair set daList lput daFirst daList ] ] [ ask righties [let daPair table:get exemplar-means daVowel let daFirst first daPair set daList lput daFirst daList ] ] report mean daList end to-report get-vowel-means-second [LorR daVowel] let daList [] ifelse LorR = "lefties" [ ask lefties [let daPair table:get exemplar-means daVowel let daSecond last daPair set daList lput daSecond daList ] ] [ ask righties [let daPair table:get exemplar-means daVowel let daSecond last daPair set daList lput daSecond daList ] ] report mean daList end ;to test-leader-exemplar-mean ; print leader-exemplar-mean(lefties)(4)(1) ;end to-report leader-exemplar-mean [LorR vNum fNum] ;; LorR should be lefties or righties ;; fNum should be 1, 2, whatever let daValues [] ask LorR with [leader? = true] [ set daValues lput (item (fNum - 1) table:get exemplar-means vNum) daValues ] report mean daValues end to-report leader-exemplar-variance [LorR vNum fNum] ;; LorR should be lefties or righties ;; fNum should be 1, 2, whatever let daValues [] ask LorR with [leader? = true] [ set daValues lput (item (fNum - 1) table:get exemplar-means vNum) daValues ] report variance daValues end to-report get-formant-value [daVowel daFormant] let daPair table:get reference-system daVowel report item (daFormant - 1) daPair end to record-breed-formant-stats ;print mean [item 0 table:get exemplar-means 1] of lefties ;269.09881666602894 ; print mean [item 0 table:get exemplar-means 1] of lefties ; ask turtle 1333 [print table:keys exemplar-means] ; [1 2 3 4 5 6 7 8] ;file-open "exemplar-means.csv" ;;file-print (word "+++++ " ticks " +++++") ;let toPrint (word "tick,Vowel,mean_turtles_first,mean_turtles_second,var_turtles_first,var_turtles_second") ;set toPrint (word toPrint ",mean_lefties_first,mean_lefties_second,mean_righties_first,mean_righties_second,variance_lefties_first") ;set toPrint (word toPrint ",variance_lefties_second,variance_righties_first,variance_righties_second") ;set toPrint (word toPrint ",mean_leaders_lefties_first,mean_leaders_lefties_second,mean_leaders_righties_first,mean_leaders_righties_second") ;set toPrint (word toPrint ",var_leaders_lefties_first,var_leaders_lefties_second,var_leaders_righties_first,var_leaders_righties_second") ;file-print toPrint ;file-close-all let mean_leaders_lefties_first -1 let mean_leaders_lefties_second -1 let mean_leaders_righties_first -1 let mean_leaders_righties_second -1 let var_leaders_lefties_first -1 let var_leaders_lefties_second -1 let var_leaders_righties_first -1 let var_leaders_righties_second -1 file-open "exemplar-means.csv" foreach [table:keys exemplar-means] of turtle 0 [ set mean_leaders_lefties_first -1 set mean_leaders_lefties_second -1 set mean_leaders_righties_first -1 set mean_leaders_righties_second -1 set var_leaders_lefties_first -1 set var_leaders_lefties_second -1 set var_leaders_righties_first -1 set var_leaders_righties_second -1 if (numberofleftyleaders > 0) [set mean_leaders_lefties_first leader-exemplar-mean(lefties)(?)(1) set mean_leaders_lefties_second leader-exemplar-mean(lefties)(?)(2) set var_leaders_lefties_first leader-exemplar-variance(lefties)(?)(1) set var_leaders_lefties_second leader-exemplar-variance(lefties)(?)(2) ] if (numberofrightyleaders > 0) [set mean_leaders_righties_first leader-exemplar-mean(righties)(?)(1) set mean_leaders_righties_second leader-exemplar-mean(righties)(?)(2) set var_leaders_righties_first leader-exemplar-variance(righties)(?)(1) set var_leaders_righties_second leader-exemplar-variance(righties)(?)(2) ] file-print (word ticks "," ? "," get-vowel-means(turtles)(?)(1) "," get-vowel-means(turtles)(?)(2) "," get-vowel-variance(turtles)(?)(1) "," get-vowel-variance(turtles)(?)(2) "," mean [item 0 table:get exemplar-means ?] of lefties "," mean [item 1 table:get exemplar-means ?] of lefties "," mean [item 0 table:get exemplar-means ?] of righties "," mean [item 1 table:get exemplar-means ?] of righties "," get-vowel-variance(lefties)(?)(1) "," get-vowel-variance(lefties)(?)(2) ;LorR vNum fNum]) "," get-vowel-variance(righties)(?)(1) "," get-vowel-variance(righties)(?)(2) "," mean_leaders_lefties_first "," mean_leaders_lefties_second "," mean_leaders_righties_first "," mean_leaders_righties_second "," var_leaders_lefties_first "," var_leaders_lefties_second "," var_leaders_righties_first "," var_leaders_righties_second ) ; end of file-print ] file-close-all end to record-variances end to record-uglies file-open "run-uglies.txt" ;; Get the size of the confusion matrices, which will be square let daSize item 0 matrix:dimensions lefty-confusions file-print (word "+++++ " ticks " +++++") foreach n-values daSize [?] [ let i ? foreach n-values daSize [?] [ let j ? let towrite matrix:get lefty-confusions i j file-type towrite if j < (daSize - 1) [file-type ","] ] file-type "\n" ] foreach n-values daSize [?] [ let i ? foreach n-values daSize [?] [ let j ? let towrite matrix:get righty-confusions i j file-type towrite if j < (daSize - 1) [file-type ","] ] file-type "\n" ] file-close-all end to-report get-pure-exemplar [which-vowel mymu] ; Only called in the pure exemplar context. let exemplar-list table:get exemplars which-vowel let locus random-exponential mymu ;print locus set locus floor locus ;print locus if locus >= length exemplar-list [set locus length exemplar-list - 1] set locus (length exemplar-list - 1 - locus) ;;print (list length exemplar-list " " locus " yo 235") if length exemplar-list = 0 [print "I'm out of here. In get-pure-exemplar." let clark 0 let robin 17 / clark] ;print exemplar-list report item locus exemplar-list end ;to-report say-yo ; print "Yo!" ; report "Done!" ;end to test ask lefty 1380 [set bob get-pure-exemplar 4 10] print bob end to testdumpconfusions ;file-open "run-pretties.txt" ; file-print (word "+++++ " ticks " +++++") ; file-print matrix:pretty-print-text lefty-confusions ; file-print matrix:pretty-print-text righty-confusions ; file-close-all let dims matrix:dimensions lefty-confusions let rows item 0 dims let cols item 1 dims print rows print cols foreach n-values rows [?] [let row ? let darow matrix:get-row lefty-confusions row ;print darow let dastr (word item 0 darow) let dalength length darow foreach n-values (dalength - 1) [?] [let index ? set dastr (word dastr "," item (index + 1) darow) ] ;set dastr (word dastr "\n") print dastr ] end to dumpconfusionscsv file-open "confusions.csv" ;file-print (word "+++++" ticks "+++++") ;file-print (word "******** lefty-confusions ***********") dumpmatrixcsv lefty-confusions "left" ;file-print (word "******** righty-confusions ***********") dumpmatrixcsv righty-confusions "right" file-close-all end to dumpmatrixcsv [amatrix rightorleft] let dims matrix:dimensions amatrix let rows item 0 dims let cols item 1 dims foreach n-values rows [?] [let row ? let darow matrix:get-row amatrix row ;print darow let dastr (word ticks "," rightorleft "," item 0 darow) let dalength length darow foreach n-values (dalength - 1) [?] [let index ? set dastr (word dastr "," item (index + 1) darow) ] ;set dastr (word dastr "\n") file-print dastr ] end ;;;;;;;;;;; sok 5/2/15 and with robin 5/4/15 testing utter-vowel to examine-utter-vowel let thelefties [] let therighties [] repeat 100 [ let result test-utter-vowel ;print result set thelefties lput item 0 result thelefties set therighties lput item 1 result therighties ] print (word mean thelefties " " mean therighties) end to-report test-utter-vowel let leftyratios [] let rightyratios [] ask lefties [let u utter-vowel let a item 0 u let b item 1 u let c item 2 u if a = 4 [set leftyratios lput (c / b) leftyratios] ] ask righties [let u utter-vowel let a item 0 u let b item 1 u let c item 2 u if a = 4 [set rightyratios lput (c / b) rightyratios] ] ;print (list variance leftyratios " " variance rightyratios) report (list variance leftyratios variance rightyratios) end ]
There is only one version of this model, created over 9 years ago by Steven Kimbrough.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.