Example #1
0
        private static IEnumerable <CsvRecord> GetRecords(double wantedChooseProbability)
        {
            foreach (var votersAmount in Enumerable.Concat(new[] { 1 }, Enumerable.Range(1, 500).Select(i => i * 10)))
            {
                var naiveCrowdIQ = new NaiveDemocracySimulation().ComputeRightVoteProbability(new NaiveDemocracySimulation.Settings
                {
                    VotersAmount            = votersAmount,
                    WantedChooseProbability = wantedChooseProbability
                });

                var factorCrowdIQ = new FactorDemocracySimulation().ComputeRightVoteProbability(new FactorDemocracySimulation.Settings
                {
                    VotersAmount            = votersAmount,
                    WantedChooseProbability = wantedChooseProbability,
                    VoteFactorStrategy      = new FactorDemocracySimulation.VoteFactorStrategyByOptimisticPercentile(),
                });

                Console.WriteLine("Voters " + votersAmount +
                                  " | Naive " + naiveCrowdIQ.ToString("0.000") +
                                  " | Factor " + factorCrowdIQ.ToString("0.000"));

                yield return(new CsvRecord
                {
                    VotersAmount = votersAmount,
                    NaiveCrowdIQ = naiveCrowdIQ,
                    FactorCrowdIQ = factorCrowdIQ
                });

                if (Math.Round(factorCrowdIQ, 2) >= 1 || Math.Round(factorCrowdIQ, 2) == 0)
                {
                    break;
                }
            }
            ;
        }
Example #2
0
        private static IEnumerable <CsvRecordSummary> GetSummaryRecords()
        {
            foreach (var wantedChooseProbability in Enumerable.Range(0, 41).Select(i => i * 0.025).Reverse())
            {
                var naiveHumanIQ = new NaiveDemocracySimulation().ComputeRightVoteProbability(
                    new NaiveDemocracySimulation.Settings
                {
                    VotersAmount            = 1,
                    WantedChooseProbability = wantedChooseProbability
                });


                foreach (var votersAmount in new[] { 50, 100 }) // new[] { 5, 10, 25, 50, 75, 100, 150, 1000, 10000 })
                {
                    var naiveCrowdIQ = new NaiveDemocracySimulation().ComputeRightVoteProbability(
                        new NaiveDemocracySimulation.Settings
                    {
                        VotersAmount            = votersAmount,
                        WantedChooseProbability = wantedChooseProbability,
                        CombinationMode         = NaiveDemocracySimulation.CombinationMode.Naive
                    });

                    var naiveGroupedCrowdIQ = new NaiveDemocracySimulation().ComputeRightVoteProbability(
                        new NaiveDemocracySimulation.Settings
                    {
                        VotersAmount            = votersAmount,
                        WantedChooseProbability = wantedChooseProbability,
                        CombinationMode         = NaiveDemocracySimulation.CombinationMode.Grouped
                    });


                    var threshold20CrowdIQ = new ThresholdDemocracySimulation().ComputeRightVoteProbability(
                        new ThresholdDemocracySimulation.Settings
                    {
                        VotersAmount            = votersAmount,
                        WantedChooseProbability = wantedChooseProbability,
                        ThresholdQuantile       = 0.2
                    });

                    var threshold50CrowdIQ = new ThresholdDemocracySimulation().ComputeRightVoteProbability(
                        new ThresholdDemocracySimulation.Settings
                    {
                        VotersAmount            = votersAmount,
                        WantedChooseProbability = wantedChooseProbability,
                        ThresholdQuantile       = 0.5
                    });

                    var optimisticPercentileWeightedCrowdIQ = new FactorDemocracySimulation().ComputeRightVoteProbability(
                        new FactorDemocracySimulation.Settings
                    {
                        VotersAmount            = votersAmount,
                        WantedChooseProbability = wantedChooseProbability,
                        VoteFactorStrategy      = new FactorDemocracySimulation.VoteFactorStrategyByOptimisticPercentile(),
                    });

                    var pessimisticPercentileWeightedCrowdIQ = new FactorDemocracySimulation().ComputeRightVoteProbability(
                        new FactorDemocracySimulation.Settings
                    {
                        VotersAmount            = votersAmount,
                        WantedChooseProbability = wantedChooseProbability,
                        VoteFactorStrategy      = new FactorDemocracySimulation.VoteFactorStrategyByPessimisticPercentile(),
                    });


                    var strict2GroupsWeightedCrowdIQ = new FactorDemocracySimulation().ComputeRightVoteProbability(
                        new FactorDemocracySimulation.Settings
                    {
                        VotersAmount            = votersAmount,
                        WantedChooseProbability = wantedChooseProbability,
                        VoteFactorStrategy      = new FactorDemocracySimulation.VoteFactorStrategyByStrict2Groups(),
                    });

                    Console.WriteLine("MeanIQ " + wantedChooseProbability.ToString("0.000") +
                                      " | Voters " + votersAmount +
                                      " | Naive " + naiveCrowdIQ.ToString("0.000") +
                                      " | Factor " + optimisticPercentileWeightedCrowdIQ.ToString("0.000"));

                    yield return(new CsvRecordSummary
                    {
                        VotersAmount = votersAmount,
                        MeanIQ = naiveHumanIQ,
                        NaiveCrowdIQ = naiveCrowdIQ,
                        NaiveGroupedCrowdIQ = naiveGroupedCrowdIQ,
                        Threshold20IQ = threshold20CrowdIQ.RightVoteProbability,
                        Threshold50IQ = threshold50CrowdIQ.RightVoteProbability,
                        OptimisticPercentileWeightedCrowdIQ = optimisticPercentileWeightedCrowdIQ,
                        PessimisticPercentileWeightedCrowdIQ = pessimisticPercentileWeightedCrowdIQ,
                        Strict2GroupsWeightedCrowdIQ = strict2GroupsWeightedCrowdIQ,
                    });
                }
                ;
            }
        }