コード例 #1
0
    private void AddDistributedNews(int nFake, int nTrue, OSN osn, double meanEFake = 0.75, double meanETrue = 0.5, double meanBFake = 0.25, double meanBTrue = 0.75)
    {
        double std           = 0.1;
        int    nPostsPerTrue = 2;

        for (int i = 0; i < nFake; i++)
        {
            double e = NormalDistribution(meanEFake, std);
            double b = NormalDistribution(meanBFake, std);
            osn.CreateNewsRandomPoster("FakeNews", false, time, e, b);
        }
        for (int j = nFake; j < nFake + nTrue; j++)
        {
            double e = NormalDistribution(meanETrue, std);
            double b = NormalDistribution(meanBTrue, std);
            osn.CreateNewsRandomPoster("TrueNews", true, time, e, b, nPostsPerTrue);
        }
    }
コード例 #2
0
    public void GraphBasedDistribute(OSN o, double onlineLit, double doesAffect)
    {
        System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
        timer.Start();
        List <Account> unspec = new List <Account>(IDCount);

        for (int i = 0; i < IDCount; i++)
        {
            unspec.Add(o.accountList[i]);
        }
        for (int i = 0; i < N_SEED; i++)
        {
            Account a = unspec[random.Next(IDCount - i)];
            a.person.PreSetEnvironmentDetermined(random.NextDouble(), NormalDistribution(onlineLit, OL_STD), NormalDistribution(ES_MEAN, ES_STD));
            unspec.Remove(a);
        }
        while (unspec.Count > 0)
        {
            Account        a  = unspec[random.Next(unspec.Count)];
            List <Account> fs = a.following;
            List <Account> rs = new List <Account>();
            foreach (Account ft in fs)
            {
                if (ft.person.isSet)
                {
                    rs.Add(ft);
                }
            }
            if (rs.Count > 0)
            {
                Account f = rs[random.Next(rs.Count)];
                //double TPL = NormalDistribution(f.person.politicalLeaning, PL_STD2) * doesAffect + random.NextDouble() * (1-doesAffect);
                //double TOL = NormalDistribution(f.person.onlineLiteracy, OL_STD2) * doesAffect + NormalDistribution(onlineLit, OL_STD+OL_STD2) * (1-doesAffect); //adding the two variances, to account for the variance of a random walk
                //double TES = NormalDistribution(f.person.emotionalState, ES_STD2) * doesAffect + NormalDistribution(ES_MEAN, ES_STD+ES_STD2) * (1-doesAffect);
                a.person.PreSetEnvironmentDetermined(NormalDistribution(f.person.politicalLeaning, PL_STD2), NormalDistribution(f.person.onlineLiteracy, OL_STD2), NormalDistribution(f.person.emotionalState, ES_STD2));
                unspec.Remove(a);
            }
        }
        foreach (Account a in o.accountList)
        {
            a.person.AdjustEnvironmentDetermined(0.5, 0.8, onlineLit, OL_STD + OL_STD2, ES_MEAN, ES_STD + ES_STD2, doesAffect);
        }
        Console.WriteLine("GBD in " + timer.ElapsedMilliseconds);
    }